feat: expose maxMemory option to prevent OOM from untrusted input#1075
Merged
feat: expose maxMemory option to prevent OOM from untrusted input#1075
Conversation
8aa0e4e to
40f7bf6
Compare
Adds `BashBuilder::max_memory(bytes)` in the Rust core that caps `max_total_variable_bytes` and clamps `max_function_body_bytes`. Exposed through JS bindings (`maxMemory`) and Python bindings (`max_memory`) on both `Bash` and `BashTool` classes. Includes Rust unit test + doctest and 5 JS security tests. Closes #1072
40f7bf6 to
4934d80
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.
Summary
BashBuilder::max_memory(bytes)convenience method in the Rust core that capsmax_total_variable_bytesand clampsmax_function_body_bytes, preventing OOM from untrusted input like exponential string doublingBashOptions.maxMemory(number, bytes) onBashandBashToolmax_memory(int, bytes) onBashandBashToolMemoryLimits+MemoryBudgetenforcement already existed — this change exposes the knob through all public APIsTest plan
test_max_memory_caps_string_growth— verifies 25 doublings of 10-byte string capped at ≤1024 bytesBashBuilder::max_memoryexample compiles and runscargo test -p bashkit --lib— 2020 tests passcargo fmt --check— cleanruff check+ruff format --check— Python lint cleanCloses #1072