Repository navigation
Limit nstun TCP receive buffers with a shared payload budget - #300
Merged
robertswiecki merged 1 commit intoAug 25, 2026
Merged
Conversation
<
8000
div class="TimelineItem js-comment-container"
data-gid="IC_kwDOAh_M6c8AAAABPMeu0A"
data-url="/google/nsjail/comments/IC_kwDOAh_M6c8AAAABPMeu0A/partials/timeline_issue_comment"
>
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
Cap retained guest-to-host TCP payload across flows so a stalled sink cannot grow the supervisor toward the per-flow limit times the maximum flow count.
HyunsikParker
force-pushed
the
codex/nstun-aggregate-budget
branch
from
August 21, 2026 19:30
136a63a to
b4cff71
Compare
Collaborator
|
Thank you! |
zerox80
pushed a commit
to zerox80/nsjail
that referenced
this pull request
Oct 16, 2026
Limit nstun TCP receive buffers with a shared payload budget
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
Security rationale
The existing 8 MiB receive-buffer cap applies independently to each TCP flow. Because one nstun context permits up to 1,024 TCP flows, a jailed process can make host destinations stop reading and drive the nsjail supervisor toward roughly 8 GiB of retained payload. This memory belongs to the supervisor and is not constrained by the jailed process's address-space limit.
The shared budget limits logical guest-to-host payload retained across IPv4 and IPv6 TCP flows to 64 MiB. When it is exhausted, nstun stops advancing the guest acknowledgment until buffered data drains, so normal TCP backpressure applies. Partial sends remain conservatively charged until the buffer is completely empty.
Local Linux proof
A bounded loopback-only proof used the real nstun TUN/TCP path with 256 redirected TCP flows and a host sink that accepted connections without reading. The jailed child had a 32 MiB address-space limit.
5ebcc30The patched supervisor remained bounded and applied backpressure instead of crashing. No external service was contacted.
Verification
make clean && makewith the project's-Werrorflagsgit diff --checkThe full
make testalso passed its focused and basic seccomp checks, but the Debianpastahelper exited in the nested Docker environment before the unrelated pasta-network test could complete.