Skip to content

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

Open
allanjoshuaf wants to merge 1 commit intoSagerNet:testingfrom
allanjoshuaf:test-zip-slip
Open

fix(clashapi): prevent zip slip in external UI download#4121
allanjoshuaf wants to merge 1 commit intoSagerNet: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

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