Skip to content

[SECURITY] Zip Slip Vulnerability: Unchecked zip extraction in input_handler.py allows arbitrary file write #109

Description

@HetCreep

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

  1. Explicitly sanitize each member path before extraction by checking that its resolved path starts with the extraction directory.
  2. For Python 3.12+, utilize the filter="data" argument in extractall().
  3. Reject extraction if any member contains directory traversal sequences (.. or Windows equivalent \..).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions