Summary
A path traversal (zip slip) vulnerability in the CTFd Admin import feature allows crafted archive files to write files outside the intended import directory.
When an administrator imports a malicious archive, an attacker can potentially plant arbitrary files elsewhere on the server filesystem, enabling configuration tampering, web shell placement, or other follow-on attacks.
Affected context
This issue affects CTFd deployments where administrators use the built-in import functionality to restore or load CTF content from uploaded archives.
The vulnerability manifests when the import process extracts files from user-supplied archives without fully normalizing and constraining file paths to a designated directory.
It is most relevant in environments where admin accounts or API keys can be obtained or misused, or where unvetted archive files are imported from external sources.
Exploit preconditions
- Attack surface: CTFd Admin import endpoint or functionality that processes uploaded archives.
- Required access: Ability to trigger an import operation with attacker-controlled archive contents (typically admin or access to an admin's session/API).
- Trigger point: Processing and extraction of paths inside the archive that include directory traversal sequences (for example, relative parent directory references).
- Why exploitation is possible: The import logic trusts archive entry paths and does not correctly normalize or enforce that extracted files remain within the intended target directory, allowing traversal outside the allowed path.
Why this happens
The underlying bug belongs to the path traversal class, specifically in the context of archive extraction commonly referred to as "zip slip."
During import, file paths stored in the archive (including components such as ../) are used directly to determine extraction locations.
Without proper canonicalization, validation, and enforcement of a fixed base directory, the extraction code can be tricked into writing files outside the designated import folder, which maps to CWE-23: Relative Path Traversal.
Potential impact
- Attacker-supplied files may be written to arbitrary locations on the server filesystem reachable by the application's write permissions.
- Application behavior could be altered by overwriting configuration, template, or content files.
- In some deployments, an attacker could place executable code (e.g., scripts or web shells) and potentially achieve remote code execution if the server executes those files.
- Log files or data files may be overwritten, leading to data loss, integrity issues, or forensic evasion.
General mitigation guidance
Effective mitigation focuses on constraining where files from imports can be written and distrusting archive entry paths.
Common defensive patterns include:
- Normalizing and canonicalizing every archive entry path, then verifying it resides within a predefined import directory before extraction.
- Stripping or rejecting any paths that contain parent directory references, absolute paths, or unexpected path separators.
- Using high-level archive extraction helpers or libraries that provide explicit safeguards against zip slip and enforce a safe base directory.
- Running the application with least-privilege filesystem permissions, ensuring that even if path traversal occurs, the process cannot write to sensitive system or application directories.
- Prefer storing imported content in isolated, non-executable directories and avoiding direct serving or execution of imported files.
How teams detect issues like this
Organizations can approach detection through:
- Static analysis: Rules or custom checks that flag archive extraction code where entry names are concatenated directly into filesystem paths without canonicalization or boundary checks.
- Code review: Looking for import/extraction routines that:
- Use archive entry names directly,
- Do not check for
.., absolute paths, or path normalization, - Lack explicit validation that the final extraction path is under a specific base directory.
- Runtime monitoring: Logging import operations and extracted file paths, then alerting on suspicious patterns such as
../segments or extractions outside expected directories. - Security testing: Incorporating crafted zip slip test archives into CI pipelines and automated security tests to validate that extraction is constrained to the correct directory.

