Repository navigation
[PR] fix: enforce the CONNECT response header limit after completion - #7166
Merged
ranxianglei merged 1 commit intoNov 20, 2026
Merged
Conversation
Apply the existing 64 KiB response-header budget whether or not the terminating delimiter is already buffered. Exclude tunneled payload bytes, and cover exact limits, split delimiters and the blind tunnel. Fixes ranxianglei#7165
This was referenced Nov 18, 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.
Fixes #7165
Problem
connectThroughProxychecks its existing 64 KiB response-header limit only while the terminating\r\n\r\nis absent. A complete 80 KiB HTTP 200 response head can therefore open a tunnel, while the same oversized head without its final delimiter is rejected. The decision depends on how the response arrives.Change
Measure the header bytes before choosing the incomplete/complete path: use the buffered length until the first delimiter appears, then use the delimiter's end offset. Reject either form above 64 KiB through the existing error/cleanup path. An exactly 64 KiB head remains accepted, and any bytes after the delimiter remain tunnel data, outside the header budget.
This is enforcement of the existing handshake bound. It does not change status-line handling, deadlines, proxy trust, authentication, configuration or the bytes forwarded through an established tunnel. The shared connection helper runs below both compression modes. No kernel, wire-message schema or model-facing text changes are included.
Validation
Tested on Node 24.22.1, bili 0.1.216, base
548e396022b9391e28a3c9061560be297779b8e8(current master when checked).setupMitm's blind-tunnel route: a bounded head forwards the complete payload; an oversized complete head returns HTTP 502.npm run typecheck,npm run build,npm run check:test-import-graphandgit diff --checkpass.Prior work
Checked 258 earlier fork heads (11 complete
upstream-proxy.tsversions, five connection-helper versions), 31 upstream file-history revisions and relevant open/closed issues and PRs. None applies the bound to a completed head. The earlier buffered-byte and premature-close changes in #6595 and #6577 address different behavior, retained by the related tests above.