You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
## What
Fix `shuf` so attacker-controlled numeric ranges and repeat counts
cannot force unbounded in-process allocation.
## Why
`shuf -i LO-HI -n N` materialized the full range before applying `-n`,
and `shuf -r -n N` collected all repeated output before interpreter
stdout truncation. Huge `u64` inputs could exhaust CPU or memory.
## How
- Represent numeric ranges separately from materialized line input.
- Sample bounded range output directly without collecting the full
range.
- Check repeat/range output against `ExecutionLimits` before allocation.
- Add regression tests for huge range `-n 1` and repeat output caps.
- Document the threat as `TM-DOS-090`.
## Risk
- Low
- `shuf` now returns an explicit error when requested output exceeds the
execution output limit instead of relying on post-command truncation.
## Checklist
- [x] Tests added or updated
- [x] Backward compatibility considered
Validation:
- `cargo fmt --check`
- `CARGO_INCREMENTAL=0 cargo clippy --all-targets -- -D warnings`
- `CARGO_INCREMENTAL=0 cargo test`
- `CARGO_INCREMENTAL=0 just vet`
- CLI smoke: huge range `-n 1` returns one line
- CLI smoke: oversized repeat exits 1 with `output too large`
Copy file name to clipboardExpand all lines: specs/threat-model.md
+2Lines changed: 2 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1339,6 +1339,7 @@ This section maps former vulnerability IDs to the new threat ID scheme and track
1339
1339
|~~TM-DOS-044~~|~~Nested `$()` stack overflow (regression)~~|~~Process crash (SIGABRT) at depth ~50 despite #492 fix~~|~~Interpreter execution path may need separate depth tracking from lexer fix~~ — depth-50 nested-subst test (`finding_nested_cmd_subst_stack_overflow::depth_50_is_bounded`) passes (**FIXED**) |
1340
1340
| TM-DOS-088 | Command substitution OOM via state cloning | OOM at depth N (memory ≈ N × state_size) | Dedicated `max_subst_depth` limit (default 32), separate from `max_function_depth` — **FIXED** via #1088|
1341
1341
| TM-DOS-089 | Command substitution stack overflow via inlined futures | SIGABRT at ~20-30 nested $() levels | Box::pin `expand_word` and `execute_cmd_subst` to cap per-level stack — **FIXED** via #1089|
1342
+
|~~TM-DOS-090~~|~~`shuf` unbounded range/repeat materialization~~|~~OOM/CPU exhaustion via huge `--input-range` or `--head-count` before stdout truncation~~|~~Sample numeric ranges without full collection and reject output that exceeds `ExecutionLimits` before allocation~~ — `shuf_resource_tests` cover huge range `-n 1` and repeat output caps (**FIXED**) |
1342
1343
1343
1344
### Accepted (Low Priority)
1344
1345
@@ -1370,6 +1371,7 @@ This section maps former vulnerability IDs to the new threat ID scheme and track
0 commit comments