fix(interpreter): add IFS word-split field and byte resource caps#2060
Merged
Conversation
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
bashkit | ebc7c4d | Commit Preview URL Branch Preview URL |
Jun 12 2026, 10:12 AM |
There was a problem hiding this comment.
Pull request overview
This PR adds execution-time resource caps to IFS word splitting to prevent CPU/memory exhaustion from expansions (notably command substitutions) that would otherwise materialize extremely large numbers of fields or bytes.
Changes:
- Introduces
ExecutionLimits::{max_word_split_fields, max_word_split_bytes}with defaults and builder setters. - Propagates IFS splitting as a
Resultand enforces limits during field production (returning aLimitExceeded::Memoryerror when exceeded). - Updates threat-model integration coverage for array-assignment behavior when word splitting would exceed configured limits.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
crates/bashkit/src/limits.rs |
Adds new execution limit knobs and updates limit-builder tests. |
crates/bashkit/src/interpreter/mod.rs |
Converts IFS splitting to fallible, enforces per-split caps, and adds unit tests for the new limits. |
crates/bashkit/tests/integration/threat_model_tests.rs |
Updates integration test expectations for array assignment overflow behavior after new split error propagation. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- ifs_split_limited: clamp effective limit to max_word_split_fields so callers passing larger values (e.g. remaining array capacity) cannot bypass the configured cap - empty-IFS branch: use stripped field length for byte accounting instead of raw s.len() which includes quote markers and overstates size - threat-model test: assert result.is_err() with limit-message check instead of loose is_err()||exit_code!=0 that masked unrelated failures
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.
Closes #2048
IFS word-splitting had no upper bound on the number of fields or total bytes produced, enabling DoS via command substitutions that emit large outputs. Adds
max_word_split_fields(default 100 000) andmax_word_split_bytes(default 10 MB) toExecutionLimits; exceeding either returns an error.