Skip to content

Add zip slip path traversal protection#1838

Open
cebarks wants to merge 3 commits intomainfrom
security/zip-slip-protection
Open

Add zip slip path traversal protection#1838
cebarks wants to merge 3 commits intomainfrom
security/zip-slip-protection

Conversation

@cebarks
Copy link
Copy Markdown
Collaborator

@cebarks cebarks commented Mar 17, 2026

Summary

  • Validate extracted paths stay within target directory using os.path.realpath() during ZIP extraction
  • Hoist real_target computation above the extraction loop for performance and correctness
  • Add same protection to instance_controller.py archive extraction (backup restore flow)
  • Add 3 tests covering traversal paths, absolute paths, and legitimate entries

Security Impact

Severity: Critical — Users can download mod ZIPs from arbitrary URLs. A malicious ZIP with entries like ../../../.bashrc could write files outside the mods directory.

Test plan

  • tests/utils/test_zip_extractor.py — 3 tests passing
  • Verify mod ZIP import (download + local) still extracts correctly
  • Verify instance backup restore still works

🤖 Generated with Claude Code

cebarks and others added 3 commits March 16, 2026 22:48
Malicious ZIP archives can contain entries with paths like ../../file
that escape the target directory. Validate that every resolved
destination path stays within the target directory before extracting.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Validate extracted paths stay within target directory using realpath
- Hoist real_target computation above the extraction loop
- Add same protection to instance_controller.py archive extraction
- Add tests for traversal, absolute path, and legitimate entries

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant