fix(sandbox): eliminate Box::leak memory leak in rewrite_forward_request#715
Merged
johntmyers merged 1 commit intomainfrom Apr 1, 2026
Merged
Conversation
Remove Box::leak usage that permanently leaked one String allocation per forward proxy request. Write the rewritten request line directly to the output buffer during iteration instead of mutating a Vec<&str> element. Closes #709
pimlock
approved these changes
Apr 1, 2026
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
Box::leakinrewrite_forward_requestthat permanently leaked oneStringallocation per forward proxy request, causing unbounded RSS growth on long-running sandboxesVec<&str>element with a leaked&'static strRelated Issue
Closes #709
Changes
crates/openshell-sandbox/src/proxy.rs—rewrite_forward_requestfunction:Box::leak(new_line.into_boxed_str())block that mutatedlines[0]with a permanently leaked allocationlinesimmutable (removedmut)METHOD absolute-uri HTTP/1.1→METHOD path HTTP/1.1) into the output-building loop, writing method/path/version parts directly viaextend_from_sliceelsebranch for malformed request lines (passes through unchanged)Testing
cargo check -p openshell-sandbox— cleancargo test -p openshell-sandbox -- proxy— 84/84 passmise run pre-commit— all checks pass (pre-existing license header issue on unrelated file)Checklist