Description
The _extract_zip method in src/skillspector/input_handler.py extracts uploaded zip files using Python's zipfile.ZipFile.extractall() without verifying or sanitizing the path names of the archived files. This permits a malicious zip file containing path traversal sequences (e.g. ../../evil.py) to write files outside the target extraction directory on the host system.
Vulnerable Code
In input_handler.py:181–182:
with zipfile.ZipFile(zip_path, "r") as zf:
zf.extractall(extract_dir) # No path or size verification
Proof of Concept
A malicious client can package a zip archive where file paths are constructed with traversal strings:
import zipfile
with zipfile.ZipFile("payload.zip", "w") as zf:
zf.writestr("../../../../tmp/evil.py", "print('exploited')")
When scanned:
skillspector scan payload.zip
The file will be extracted outside extract_dir (e.g. into /tmp/evil.py).
Remediation
- Explicitly sanitize each member path before extraction by checking that its resolved path starts with the extraction directory.
- For Python 3.12+, utilize the
filter="data" argument in extractall().
- Reject extraction if any member contains directory traversal sequences (
.. or Windows equivalent \..).
Description
The
_extract_zipmethod insrc/skillspector/input_handler.pyextracts uploaded zip files using Python'szipfile.ZipFile.extractall()without verifying or sanitizing the path names of the archived files. This permits a malicious zip file containing path traversal sequences (e.g.../../evil.py) to write files outside the target extraction directory on the host system.Vulnerable Code
In input_handler.py:181–182:
Proof of Concept
A malicious client can package a zip archive where file paths are constructed with traversal strings:
When scanned:
The file will be extracted outside
extract_dir(e.g. into/tmp/evil.py).Remediation
filter="data"argument inextractall()...or Windows equivalent\..).