Skip to content

fix(interpreter): prevent brace step overflow#1825

Merged
chaliy merged 1 commit into
mainfrom
2026-06-02-propose-fix-for-brace-expansion-vulnerability
Jun 2, 2026
Merged

fix(interpreter): prevent brace step overflow#1825
chaliy merged 1 commit into
mainfrom
2026-06-02-propose-fix-for-brace-expansion-vulnerability

Conversation

@chaliy
Copy link
Copy Markdown
Contributor

@chaliy chaliy commented Jun 2, 2026

Motivation

  • Prevent DoS and non-terminating brace expansions where large or specially-crafted ..step values could overflow or leave the loop unadvanced, bypassing the existing range-size cap and causing panics or unbounded resource growth.

Description

  • Use i128 arithmetic for numeric brace range stepping by converting the step magnitude to i128 and iterating i and end as i128 so valid large i64 steps cannot overflow during iteration.
  • Preserve the precomputed range-size cap (MAX_BRACE_RANGE) and the existing validation logic that rejects zero or non-numeric steps.
  • Add a regression unit test test_try_expand_range_numeric_large_step_does_not_overflow that asserts correct behavior for ascending and descending large-step numeric ranges near i64 bounds.
  • Modified file: crates/bashkit/src/interpreter/mod.rs.

Testing

  • Ran cargo fmt --check and it passed.
  • Ran cargo test -p bashkit test_try_expand_range_numeric_large_step_does_not_overflow --lib and it passed.
  • Ran cargo test -p bashkit test_try_expand_range_alpha_large_step_does_not_loop --lib and it passed.

Codex Task

@cloudflare-workers-and-pages
Copy link
Copy Markdown

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

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 b4eb923 Commit Preview URL Jun 02 2026, 09:27 AM

@chaliy chaliy force-pushed the 2026-06-02-propose-fix-for-brace-expansion-vulnerability branch from 0c6d99e to b4eb923 Compare June 2, 2026 09:19
@chaliy chaliy merged commit 8d5f772 into main Jun 2, 2026
34 checks passed
@chaliy chaliy deleted the 2026-06-02-propose-fix-for-brace-expansion-vulnerability branch June 2, 2026 13:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant