Repository navigation
fix(tools): enforce ExecuteBashTool resource limits that are set to 0 - #7984
Open
Fruiterer333 wants to merge 1 commit into
Open
Fruiterer333 wants to merge 1 commit into
Fruiterer333 wants to merge 1 commit into
Conversation
Fruiterer333
force-pushed
the
fix/bash-tool-zero-resource-limits
branch
from
November 4, 2026 02:54
b3314dd to
af51dd0
Compare
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.
Link to Issue or Description of Change
1. Link to an existing issue (if applicable):
Problem:
_set_resource_limitschecked each limit withif policy.max_file_size_bytes:. A limit of0is falsy, sosetrlimitwas never called for it and the command ran with no limit.BashToolPolicy(max_file_size_bytes=0)let a command write files of any size, andmax_child_processes=0did not stop it from starting child processes.Solution:
The three limits are now checked with
is not None.Noneis still the default and still means no limit;0is now passed tosetrlimitlike any other value. TheBashToolPolicydocstring now says that0is enforced.Testing Plan
Unit Tests:
I have added or updated unit tests for my change.
All unit tests pass locally.
Added two tests to
tests/unittests/tools/test_bash_tool.py; both fail onmain:test_zero_resource_limits_are_enforced: with all three limits at0,setrlimitis called forRLIMIT_AS,RLIMIT_FSIZEandRLIMIT_NPROCwith(0, 0).test_zero_file_size_limit_blocks_file_writes: withmax_file_size_bytes=0, a realddcommand that writes 4096 bytes fails and the file stays empty.Manual End-to-End (E2E) Tests:
Ran the reproduction script from the issue:
Checklist
Additional context
I used Claude Code to help find the issue and draft the change; I reproduced the bug and verified the fix and tests locally.