Skip to content

fix(clashapi): prevent zip slip in external UI download#4121

Closed
allanjoshuaf wants to merge 78 commits into
SagerNet:testingfrom
allanjoshuaf:test-zip-slip
Closed

fix(clashapi): prevent zip slip in external UI download#4121
allanjoshuaf wants to merge 78 commits into
SagerNet:testingfrom
allanjoshuaf:test-zip-slip

Conversation

@allanjoshuaf
Copy link
Copy Markdown

Summary

Fix a Zip Slip path traversal vulnerability in downloadZIP() used by external UI downloads.

The extracted file path is now validated to ensure it remains inside the configured output directory after path normalization.

Changes

  • Added path containment validation using filepath.Clean
  • Reject ZIP entries attempting directory traversal outside the output directory
  • Added regression test covering malicious ZIP traversal entries

Testing

Added TestDownloadZIPZipSlip which:

  • creates an in-memory ZIP archive containing a traversal payload (../../../pwned.txt)
  • verifies that downloadZIP() rejects the archive
  • verifies that no file is written outside the target directory

Related: #4117

@nekohasekai nekohasekai force-pushed the testing branch 6 times, most recently from 057f540 to 6b07a22 Compare May 15, 2026 05:29
@allanjoshuaf
Copy link
Copy Markdown
Author

allanjoshuaf commented May 16, 2026

Superseded by #4142

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.

3 participants