Skip to content

bug: prevent Zip Slip path traversal in archive import - #234

Open
devin-ai-integration[bot] wants to merge 1 commit into
mainfrom
devin/1787665382-zip-slip-fix
Open

bug: prevent Zip Slip path traversal in archive import#234
devin-ai-integration[bot] wants to merge 1 commit into
mainfrom
devin/1787665382-zip-slip-fix

Conversation

@devin-ai-integration

@devin-ai-integration devin-ai-integration Bot commented Aug 25, 2026

Copy link
Copy Markdown

Summary

/import extracted uploaded zips with zip.extractAllTo('/tmp/extracted_files', true) (adm-zip 0.4.7, no entry-name validation), so an archive entry named ../../../../root/.ssh/authorized_keys or an absolute path wrote outside the extraction directory.

Replaced it with safeExtractAllTo(zip, target), which iterates zip.getEntries() and writes each entry itself after checking containment:

var destination = path.resolve(target, entryName.replace(/\\/g, '/'));
if (isAbsolute(name) || (destination !== target && !destination.startsWith(target + path.sep))) skip;

Backslashes are normalized (Windows-style separators in entry names), absolute and drive-letter names are rejected, directories are created with mkdirSync(..., {recursive:true}), and files are written with entry.getData(). Skipped entries are logged; safe entries, including nested paths, extract as before.

Verified locally with a crafted archive containing good.txt, sub/dir/f.txt, ../../../../tmp/pwned.txt and /tmp/abs_pwned.txt: both traversal entries were skipped (no files written outside /tmp/extracted_files) and the benign entries extracted.

Devin-Org: engineering


Devin Review

Status Commit
⚪ Not started

Run Devin Review

Devin Review (Staging)

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.

0 participants