New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
proposal: crypto/tls: make maxHandshake configurable #50773
Comments
Yes: making something configurable is backwards-compatible as long as the default behavior remains the same. (We can be certain that no existing program configures it to anything other than the default.) |
cc @golang/security |
CC @golang/security Looks like this didn't make 1.19. Moving to backlog. Please recategorize as appropriate. Thanks. |
I've found real-world case where I can't connect to development server. The server has some extremely long list of SANs, but the certificate is still valid and works for at least for Also JDK has it's setting |
Is there a concrete API proposal here, It sounds like essentially what is wanted is a new field on tls.Config? i.e.
|
What is the best way to move this forward? I can create an API proposal (similar to this) and provide an implementation if desired. |
If 64kB is no longer a reasonable upper limit, it seems like we should bump to a new reasonable limit. That wouldn't be an API change. |
I propose going directly to the maximum length provided by the spec (16MB), unless there are performance or security concerns that make this infeasible. |
Could there be some users that are implicitly relying on the low default limit to mitigate the threat of resource exhaustion attacks? There's no way to currently specify a request size limit in Given how rarely this limit is run into, it might be safer to provide configurability rather than a change in behaviour. At some point (maybe even at the same time) the default can also be raised somewhat. This is mainly a theoretical concern though and I'm not sure this would actually be a problem in practice. I'm just worried about internet-exposed servers suddenly being vulnerable to DDoS by a client opening thousands of connections with large handshakes then holding the connections open until timeout. This was the original motive for having a low limit, I imagine. |
This proposal has been added to the active column of the proposals project |
This cap limits how much memory we can be made to allocate in a handshake (which happens before anything higher level such as net/http is brought in). We should not go straight to 16MiB. If the only message that can conceivably be that big is the Certificates message, let's just make the cap for that specific message 256KiB or something like that. That way most servers will be unaffected, and anyway it takes more work to do a DoS than just spamming giant Client Hello messages. |
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
What did you expect to see?
I expected the connection to succeed.
What did you see instead?
tls: handshake message of length 110013 bytes exceeds maximum of 65536 bytes
The limit is defined here:
and it says that the protocol max is 16 MB, not 64 KiB. I assume this hard limit is to mitigate resource exhaustion attacks, but it would be preferable if it was configurable.
Context
We dynamically generate certificates for mTLS within and across clusters and configure which services are allowed to open connections between each other using Subject Alternative Names. In extreme cases a service that needs to communicate with many other services could have a certificate that's larger than this limit.
This isn't a problem right now but a limit of 64 KiB provides a fairly small and uncomfortable safety buffer. Is there a reason that this limit is not configurable?
This issue is related to #35153 where @FiloSottile says "Documenting something makes it a backwards compatibility promise". Is making it configurable still possible while preserving backwards compatibility in the future?
The text was updated successfully, but these errors were encountered: