Skip to content

[hotfix][java][python] Harden Bash arithmetic evaluation - #1083

Merged
wenjin272 merged 1 commit into
apache:mainfrom
wenjin272:codex/fix-bash-arithmetic-sandbox-escape
Sep 2, 2026
Merged

[hotfix][java][python] Harden Bash arithmetic evaluation#1083
wenjin272 merged 1 commit into
apache:mainfrom
wenjin272:codex/fix-bash-arithmetic-sandbox-escape

Conversation

@wenjin272

Copy link
Copy Markdown
Contributor

Linked issue: N/A (hotfix)

Purpose of change

Bash can reinterpret values during integer declarations and arithmetic expansion after the original command has passed AST validation. This creates execution paths that are not covered by the command allowlist.

This change applies the same fail-closed policy in Java and Python:

  • reject declaration commands;
  • reject arithmetic expansions;
  • reject standalone variable assignments while preserving assignment prefixes attached to an allowed executable; and
  • add validator and tool-level regression coverage for both indirect evaluation paths.

This intentionally makes validation stricter: benign declaration commands, arithmetic expansions, and standalone assignments are also rejected.

Tests

  • pytest -q python/flink_agents/plan/tools/bash/tests/test_bash_tool.py (46 passed)
  • mvn -pl plan -am -DskipITs -Dtest=BashValidatorTest,BashToolTest -Dsurefire.failIfNoSpecifiedTests=false test (21 passed)
  • JAVA_HOME=/Users/jhin/Kit/jdk-17.0.2.jdk/Contents/Home mvn -pl plan -am -DskipITs test (713 tests, 0 failures/errors, 12 skipped)
  • ruff check and ruff format --check for the changed Python files
  • git diff --check

API

No public API changes. Bash tool validation behavior is intentionally stricter.

Documentation

  • doc-needed
  • doc-not-needed
  • doc-included

Was this patch authored or co-authored using generative AI tooling?

  • Yes
  • No

Generated-by: Codex (GPT-5)

Reject declaration commands, arithmetic expansions, and standalone variable assignments that Bash can reinterpret outside the validated AST. Add mirrored Java and Python regression coverage.

Generated-by: Codex (GPT-5)

Co-authored-by: Codex <[email protected]>
@github-actions github-actions Bot added doc-not-needed Your PR changes do not impact docs fixVersion/0.4.0 priority/major Default priority of the PR or issue. labels Sep 1, 2026
@wenjin272
wenjin272 marked this pull request as ready for review September 2, 2026 01:40
@wenjin272
wenjin272 merged commit 388d4b8 into apache:main Sep 2, 2026
28 checks passed
wenjin272 added a commit that referenced this pull request Sep 2, 2026
Generated-by: Codex (GPT-5)

Co-authored-by: Codex <[email protected]>
(cherry picked from commit 388d4b8)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

doc-not-needed Your PR changes do not impact docs fixVersion/0.4.0 priority/major Default priority of the PR or issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant