Skip to content

ENG-1640: Confine untrusted archive extraction under the destination root#3815

Open
mitchell-as wants to merge 1 commit into
mitchell/eng-1632from
mitchell/eng-1640
Open

ENG-1640: Confine untrusted archive extraction under the destination root#3815
mitchell-as wants to merge 1 commit into
mitchell/eng-1632from
mitchell/eng-1640

Conversation

@mitchell-as

@mitchell-as mitchell-as commented Jun 22, 2026

Copy link
Copy Markdown
Collaborator

ENG-1640: Contain decrypted installs: path sanitization, private temps, user isolation

Part of the private ingredient work (ENG-1563). Private ingredient wheels come from untrusted sources, so their extraction must not be able to write or point anywhere outside the destination directory.

Unarchive now takes a WithUntrustedSource option. When set, every entry path, symlink target, and hardlink target is confined under the destination root, and anything that escapes aborts extraction. It's off by default — trusted Platform artifacts may legitimately contain absolute symlinks (e.g. into /usr/share), so their extraction is unchanged. The decrypt-and-install path (ENG-1635) will extract private wheels with this option.

Scope: just the extraction sanitizer. The decrypt temp dir and per-user isolation of decrypted content are deferred to ENG-1635, where they're applied at the deploy site.

Base branch: targets mitchell/eng-1632 (in review) so the diff is only this change; GitHub will retarget it to version/0-48-1-RC2 once the upstream PRs land.

Tested with successful and rejected (untrusted) tar.gz fixtures, the same escaping archive extracting when trusted, a zip happy path, and contained symlink/hardlink extraction.

🤖 Generated with Claude Code

…1640)

Private ingredient wheels come from untrusted sources, so their extraction must
not be able to write or point anywhere outside the destination directory.

Unarchive now takes a WithUntrustedSource option. When set, every entry path,
symlink target, and hardlink target is confined under the destination root and
anything that would escape aborts extraction. It is off by default: trusted
Platform artifacts may legitimately contain absolute symlinks (for example into
/usr/share), so their extraction is unchanged.

The ENG-1635 decrypt path will extract private wheels WithUntrustedSource; per-
user isolation of decrypted content and the decrypt temp dir are handled there.

testfile.tar.gz is a contained fixture backing the successful-extraction test;
the previous fixture, which has a root-level escaping symlink, is renamed to
testfile-escapes.tar.gz and backs the rejection test.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@mitchell-as mitchell-as changed the title ENG-1640: Confine archive extraction paths under the destination root ENG-1640: Confine untrusted archive extraction under the destination root Jun 22, 2026
@mitchell-as

Copy link
Copy Markdown
Collaborator Author

Test failures are known or sporadic and unrelated to this PR.

@mitchell-as mitchell-as requested a review from MDrakos June 22, 2026 21:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant