h2o / picotls

TLS 1.3 implementation in C (master supports RFC8446 as well as draft-26, -27, -28)
527 stars 140 forks source link

detect and report TLS buffer overflows #504

Closed kazuho closed 6 months ago

kazuho commented 7 months ago

Up until now, when generating TLS messages, we have ignored the overflow of length fields. When they overflow, we have been sending length fields that contains the modulo of the actual length.

This does not happen in practice (as the endpoints control what they send in the handshake messages, which tend to be much smaller than the limits), and even if they fail the behavior is not harmful in sense that they end up in TLS handshake failures, but it is better to report them as errors.

Therefore, this PR adds such logic. A new error code is defined that would be reported to the application. The error code sent on wire will be Internal Error, which is the same error code that we send when running out of memory.