Skip to content

fix(analysis): flag arithmetic command substitutions - #2283

Merged
chaliy merged 1 commit into
mainfrom
2026-08-07-fix-analysis-of-arithmetic-substitutions
Aug 7, 2026
Merged

fix(analysis): flag arithmetic command substitutions#2283
chaliy merged 1 commit into
mainfrom
2026-08-07-fix-analysis-of-arithmetic-substitutions

Conversation

@chaliy

@chaliy chaliy commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Motivation

  • The analysis walker ignored WordPart::ArithmeticExpansion, letting runtime $() inside arithmetic expressions execute hidden commands without being reported.
  • This allowed scripts like echo $(( $(rm -rf /data; echo 1) + 2 )) to appear non-opaque and bypass pre-execution permission prompts, violating the analysis security contract.

Description

  • Mark arithmetic expansions that contain $(...) as substitutions by setting has_command_substitution and conservatively setting has_dynamic_commands in walk_word_parts of crates/bashkit/src/analysis.rs so is_opaque() becomes true.
  • Add a regression unit test analysis::tests::command_substitution_in_arithmetic_is_opaque that asserts arithmetic-embedded $(...) is reported and makes the analysis opaque.
  • Update the knowledge/integrations/script-analysis.md and knowledge/security/threat-model.md guidance to document arithmetic-embedded command-substitution behavior and the mitigation for TM-ESC-032.

Testing

  • Ran cargo test -p bashkit analysis::tests::command_substitution_in_arithmetic_is_opaque --lib which passed.
  • Ran the suite cargo test -p bashkit analysis::tests --lib which passed (all modified analysis tests succeeded).
  • Ran style and policy checks cargo fmt --check, cargo clippy --all-targets -- -D warnings, and just check-okf which completed successfully.

Codex Task

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Aug 7, 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 67d6765 Commit Preview URL Aug 07 2026, 09:30 AM

@chaliy
chaliy force-pushed the 2026-08-07-fix-analysis-of-arithmetic-substitutions branch from cf62fde to 67d6765 Compare August 7, 2026 09:29
@chaliy
chaliy merged commit d555db7 into main Aug 7, 2026
42 checks passed
@chaliy
chaliy deleted the 2026-08-07-fix-analysis-of-arithmetic-substitutions branch August 7, 2026 09:40
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