Skip to content

fix(interpreter): add IFS word-split field and byte resource caps#2060

Merged
chaliy merged 2 commits into
mainfrom
fix/pr-2048-ifs-word-split-caps
Jun 12, 2026
Merged

fix(interpreter): add IFS word-split field and byte resource caps#2060
chaliy merged 2 commits into
mainfrom
fix/pr-2048-ifs-word-split-caps

Conversation

@chaliy

@chaliy chaliy commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

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) and max_word_split_bytes (default 10 MB) to ExecutionLimits; exceeding either returns an error.

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Jun 12, 2026

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

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

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 Result and enforces limits during field production (returning a LimitExceeded::Memory error 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.

Comment thread crates/bashkit/src/interpreter/mod.rs
Comment thread crates/bashkit/src/interpreter/mod.rs
Comment thread crates/bashkit/tests/integration/threat_model_tests.rs
- 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
@chaliy chaliy merged commit 8bd7b87 into main Jun 12, 2026
36 checks passed
@chaliy chaliy deleted the fix/pr-2048-ifs-word-split-caps branch June 12, 2026 10:35
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.

2 participants