Summary
MarkUs contains a path traversal vulnerability in the assignment configuration import feature where file names from uploaded ZIP archives are used directly to construct filesystem paths.
An attacker who can upload a crafted configuration ZIP may cause files to be written outside the intended directory, potentially overwriting sensitive files and compromising the server.
Affected context
This issue affects MarkUs deployments that allow instructors (or any role with equivalent permissions) to upload ZIP files to create assignments from exported configurations at courses/<course_id>/assignments/upload_config_files.
The vulnerability occurs during ZIP extraction when the application derives filesystem paths directly from ZIP entry names without normalizing or constraining them to a specific base directory.
It is most relevant in environments where the MarkUs process has write access to sensitive directories or critical application/configuration files.
Exploit preconditions
- Attack surface: HTTP endpoint handling assignment configuration ZIP uploads (
upload_config_files). - Required access: Ability to authenticate as an instructor or any role permitted to upload assignment configuration ZIPs.
- Trigger point: Uploading a crafted ZIP archive whose entry names contain directory traversal sequences (e.g.,
../) or absolute-like paths. - Why exploitation is possible: The application trusts ZIP entry names and concatenates them into filesystem paths without proper sanitization, canonicalization, or enforcement of a safe base directory, allowing writes outside the intended assignment configuration folder.
Why this happens
The root cause is improper path handling when processing ZIP archive contents, mapped to CWE-23: Relative Path Traversal.
The code responsible for importing assignment configurations uses entry names from the uploaded ZIP to build destination paths and writes files directly to disk.
Without canonicalizing paths and verifying that the resolved path remains within a designated root directory, attackers can leverage traversal sequences to escape the target directory and influence arbitrary locations within the filesystem that are writable by the MarkUs process.
Potential impact
- Overwriting existing application files that the MarkUs process can write to.
- Writing malicious files (e.g., executable scripts or configuration files) outside the assignment directory.
- Potential escalation to remote code execution if written files are later executed or interpreted by the application stack or web server.
- Corruption or tampering of course, grading, or configuration data stored on the filesystem.
- Disruption of service by corrupting critical data or configuration.
General mitigation guidance
Effective mitigations focus on robust path validation and strict write confinement:
- Normalize and canonicalize all paths derived from ZIP entry names before writing files.
- Enforce that all resolved paths remain within a predefined base directory (e.g., the assignment configuration directory) by checking the canonical path prefix.
- Reject or sanitize entries containing directory traversal sequences (
../, leading slashes, drive letters) or other anomalous patterns. - Limit filesystem permissions of the MarkUs runtime user to the minimal directories required for normal operation.
- Consider using higher-level libraries or helper functions that provide safe archive extraction primitives with built-in path confinement.
These patterns reduce the likelihood that untrusted archive content can influence arbitrary parts of the filesystem.
How teams detect issues like this
Detection typically combines code-level review with operational monitoring:
- Static analysis: Flag any file write operations where paths are built from user-controlled input (such as ZIP entry names) without normalization and base-directory checks.
- Code review: Look for custom archive extraction logic that does not:
- Canonicalize paths before use, and
- Explicitly validate that the final path remains under a known safe root.
- Logging and monitoring: Monitor for unexpected file creation or modification outside designated assignment directories, especially around times of configuration uploads.
- Security testing: Include archive upload tests in application security assessments, attempting directory traversal via ZIP entries to ensure extraction routines enforce proper constraints.
Automated SAST or CI-integrated scanners can help flag risky path concatenation patterns early in development.

