Skip to content

fix(prover): confine tarball extraction to the target directory - #2938

Open
zexoverz wants to merge 3 commits into
succinctlabs:mainfrom
zexoverz:harden-tarball-extraction
Open

zexoverz wants to merge 3 commits into
succinctlabs:mainfrom
zexoverz:harden-tarball-extraction

Conversation

@zexoverz

Copy link
Copy Markdown

Fixes #2533.

A note on where this lives: the issue points at crates/sdk/src/install.rs, which is now an eight-line re-export. The implementation is in crates/prover/src/build.rs.

There are two extraction sites there, not one. download_circuit_artifacts pulls the circuit artifacts over HTTPS, and the dev-artifact path pulls from S3 via aws s3 cp. Both passed -P, so both accepted absolute member names and .. components. Only the first is mentioned in the issue.

Both now go through a shared extract_tarball helper that omits -P. Nothing needed it. The tarballs are produced with relative paths by the upload path in this same file (tar -czf ... -C <dir> .), and the repository's other two extraction sites, the CUDA server download and the toolchain installer, already extract without -P. This brings the outliers in line rather than introducing a new convention.

Two tests build genuinely hostile archives, one with a ../ member and one with an absolute member, and assert neither writes above the extraction directory. I checked they fail with -P restored, so they pin the behaviour rather than just passing. The absolute-path test demonstrates the overwrite directly: without the fix, a file outside the extraction directory is reverted to the archive's copy.

The two tars behave differently on the hostile input, so the tests assert only the property that matters. GNU tar strips the offending components and continues; bsdtar refuses the entry and exits non-zero. Both confine the write, which is what is asserted.

I have not attempted to address symlink-based escapes, which are a separate class and would mean moving off the tar binary entirely. Happy to look at that separately if you want it.

zexoverz and others added 2 commits August 18, 2026 23:36
Both extraction sites in `crates/prover/src/build.rs` invoked tar with `-P`
(`--absolute-names`), which permits absolute member names and `..` components.
The archives reaching them are downloaded over the network, so a substituted or
compromised artifact could write outside the build directory.

Route both through a shared `extract_tarball` helper that omits `-P`. Nothing
needs it: the tarballs are produced with relative paths by the upload path in
this same file, and the repository's other two extraction sites (the CUDA server
download and the toolchain installer) already extract without `-P`.

Add two tests that build genuinely hostile archives, one with a `../` member and
one with an absolute member, and assert neither writes above the extraction
directory. Both fail if `-P` is restored.
@zexoverz

Copy link
Copy Markdown
Author

Ten days in and no workflow has run on this yet. Could a maintainer approve the run? It is a path traversal fix so I would rather it not sit.

This branch has not been deployed

No deployments
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.

[H] Tar extraction allows arbitrary file overwrite

1 participant