Bump maximum header size to 4KiB, alternative version#155
Merged
pires merged 4 commits intopires:mainfrom Feb 5, 2026
Merged
Conversation
This was referenced Feb 5, 2026
pires
reviewed
Feb 5, 2026
pires
reviewed
Feb 5, 2026
Owner
pires
left a comment
There was a problem hiding this comment.
I am conceding on increasing the max V2 header size to 4KB as it seems to fix the issues observed by @clementnuss and others.
Up until now we were using Peek to ensure (1) the client sent at least the number of bytes announced in the length field and (2) the client doesn't exceed a 256 byte limit. This wasn't very explicit, and forces each connection to pay an up-front memory cost of the largest header size we want to accept. Instead, add an explicit check for the max header size (to avoid DoS), and check that all bytes have been read from the io.LimitedReader.
PP2_SUBTYPE_SSL_CLIENT_CERT is typically around 1 or 2KiB.
Add a test with a 2KiB TLV, which is typical for PP2_SUBTYPE_SSL_CLIENT_CERT.
This is important to check for security purposes: all TLVs are buffered in memory, and we don't want clients to be able to cause a DoS due to ENOMEM.
pires
approved these changes
Feb 5, 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.
Alternative to #144 and #150. Based on #154.
See individual commits.