T09 · Insecure Skill Coding Practices
- Location
scripts/unzip.py:8- Finding
Unconditional Overwrite of Existing Files During ZIP Extraction
- Content
View full analysis
Vulnerability Details
File Location:
scripts/unzip.py, lines 8-9
Vulnerability Type: Uncontrolled file overwrite
Risk Level: Mediumpython with zipfile.ZipFile(args.file, 'r') as z: z.extractall(args.dir)Technical Analysis
The application passes every member of a user-supplied ZIP archive directly to
zipfile.ZipFile.extractall(). It does not inspect destination collisions or require explicit authorization before replacing existing regular files.This behavior is also inconsistent with the overwrite controls documented in
SKILL.md: the documentation advertises-oand-n, but the argument parser implements neither option. Consequently, overwriting is effectively always enabled, and users cannot request the documented never-overwrite behavior.An attacker can construct an archive whose member names match predictable files in a destination directory. If a user extracts that archive into a populated directory, matching files can be replaced without warning. The issue does not independently grant privileges beyond those of the invoking process.
Attack Path
- An attacker creates a ZIP archive containing files named after predictable project or configuration files.
- The attacker persuades a user or automated process to extract the archive using this Skill.
- The user selects a populated directory using
-d, or extracts into the default current directory. extractall()processes all archive members without checking whether their destination paths already exist.- Existing matching regular files are replaced using the permissions of the invoking process.
- The replacement can cause data loss or modify project behavior when the affected files are subsequently used.
Impact Assessment
Exploitation can compromise the integrity and availability of files writable by the invoking user within the selected extraction destination. Potential consequences include loss of exist ...[truncated 309 chars]
- Remediation
View remediation
Remediation Suggestions
- Make refusal to overwrite existing files the default policy.
- Implement mutually exclusive
--overwriteand--never-overwriteoptions, matching the behavior documented inSKILL.md. - Inspect every archive member before extraction and calculate its final destination path.
- Detect destination collisions before writing any files. Abort the operation or skip conflicting members unless overwrite permission was explicitly supplied.
- Extract validated members individually instead of calling
extractall()without policy enforcement. - Consider using a staging directory and moving validated files into the destination only after all archive members pass validation.
- Return a nonzero exit status when validation or extraction fails so automated callers can reliably detect unsuccessful or partial extraction.
- Add tests covering existing-file collisions, default behavior, explicit overwrite behavior, never-overwrite behavior, and partially conflicting archives.
