Summary
A path traversal vulnerability in Marker's FastAPI /marker/upload handler allows unauthenticated attackers to submit filenames containing directory traversal sequences. If the server processes these filenames without enforcing a safe storage location, an attacker may write arbitrary files or delete existing files.
Affected context
The vulnerability occurs in deployments that expose the FastAPI /marker/upload endpoint and use the client-controlled file.filename value when constructing filesystem paths. Risk is higher when the service runs with permissions to modify sensitive directories or when uploaded files are processed before their names are normalized and constrained to an intended storage directory.
Exploit preconditions
- Attack surface: The publicly reachable FastAPI
/marker/uploadendpoint - Required access: No authentication may be required
- Trigger point: Upload handling when the supplied filename is used in a filesystem operation
- Why exploitation is possible: Directory traversal sequences can cause the resolved path to escape the intended upload directory, enabling unauthorized file writes or deletion where process permissions allow
Why this happens
The underlying bug is reliance on an externally supplied filename without securely resolving and validating its filesystem path. This is an instance of CWE-73: External Control of File Name or Path, where attacker-controlled input influences a file operation and can alter the target location. The insecure pattern is treating a client-provided name as a trusted path component instead of reducing it to a safe identifier and enforcing containment within an approved directory.
Potential impact
- An attacker may overwrite application, configuration, or operational files
- An attacker could delete files accessible to the service account
- The application may experience denial of service or startup failures
- File writes could enable follow-on code execution depending on file type, location, and runtime permissions
- Sensitive data may be altered or operational integrity compromised
General mitigation guidance
Mitigation generally focuses on removing trust from client-controlled filenames and enforcing filesystem boundaries.
Common defensive patterns include:
- Generate server-side filenames or use opaque object identifiers rather than preserving client-supplied paths
- Normalize and validate names before any filesystem operation
- Resolve the final path and verify that it remains within a dedicated upload directory
- Reject absolute paths, traversal components, unexpected separators, and ambiguous encodings
- Separate uploaded content from executable, configuration, and system directories
- Apply least-privilege permissions to the service account and filesystem
- Use controlled file APIs and explicit allowlists for permitted storage locations
- Avoid destructive file operations based solely on request-supplied names
How teams detect issues like this
High-level detection approaches include:
- Static analysis rules that identify request filename values flowing into path joins, open, rename, unlink, or delete operations
- Code review checks for direct use of multipart filename fields in filesystem paths
- Tests covering traversal markers, absolute paths, encoded separators, and platform-specific path syntax
- Runtime logging of normalized and rejected upload names without recording sensitive content
- Web application firewall or API policy rules that reject suspicious path components
- File-integrity monitoring for unexpected changes outside the designated upload area
- Automated security review tools that flag externally controlled path construction

