Repository navigation
fix(security): bound tar lists and nested substitution parsing - #2678
Merged
Merged
Conversation
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
bashkit | 9e72082 | Commit Preview URL Branch Preview URL |
Oct 11 2026, 06:52 PM |
chaliy
marked this pull request as ready for review
October 11, 2026 18:40
2 tasks done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changed
Tar file lists now charge input, work, and live retained capacity before reading, decoding, or growing per-name storage. File, stdin, repeated-list, and long-option forms preserve order, duplicates, CRLF handling, and malformed UTF-8 replacement.
Nested command substitutions now consume the enclosing AST depth and preserve its timeout origin. Heap-owned child parsers and private command results, plus outlined nonrecursive parameter parsing and AST assembly, prevent native stack overflow on default 2 MiB test-thread stacks. The existing 100-level ceiling and public AST format remain unchanged.
The feature suite also exposed unreliable embedded CPython module alignment on macOS. Module bytes now retain a cached immutable aligned copy when linking or ASLR does not preserve 64 KiB alignment; the original alignment assertion is unchanged, and byte-preservation and repeated-load tests pass.
Why
A dense
tar -Tlist bypassed live-memory accounting. The full ship gate also reproduced a depth-50 substitution SIGABRT on clean main: child parsers reset depth and retained large debug-build stack frames. Both resource failures must return bounded errors without terminating the host.Before / After
cargo test depth_50_is_bounded -- --nocaptureaborted with SIGABRT on clean main508967f5; a new four-level substitution with a three-level AST limit incorrectly parsed.AST nesting too deep; no nested file write occurs, the shell recovers, and moderate nesting matches/bin/bashstdout, stderr, and exit status.Validation on
9e72082a: fulljust pre-pr,just testwith serialized failpoints, all-features Clippy, security proptests, rustdoc preview, builtin inventory, and tar/CPython CLI smoke tests pass. All 49 PR checks are green. All 33 Criterion cases completed with default sample counts; the CPU-bounded runner required separate subprocess groups. The 96-case Bash comparison harness has zero errors and 100% expected-output matches on main and this revision; aggregate Bashkit time was 27.71 ms before and 25.06 ms after in this run. Single-operation timing changes were about -1% to +2%. Parallel timings were unstable on the active desktop: initial 100/200-session slowdowns changed substantially in back-to-back repeats, with both unchanged results and large spikes. Fresh 200- and 1,000-session repeats detected no statistically significant change. These measurements do not establish a stable parallel performance change; raw runs and repeat evidence are retained.Risk
Medium: parser frame layout and private ownership affect shared grammar paths. Existing grammar, quoting, function printing, aliases, and security tests run unchanged. CPython may retain one additional module-sized copy plus less than 64 KiB padding on unaligned hosts. No dependency, stack-size, depth-ceiling, test-skip, or CI-policy changes.
Checklist