Skip to content

fix: fail reads clearly when the peer sends a TLS 1.3 KeyUpdate - #75

Merged
cpu merged 1 commit into
rustls:mainfrom
ArniDagur:fix-keyupdate-clear-error
Aug 7, 2026
Merged

fix: fail reads clearly when the peer sends a TLS 1.3 KeyUpdate#75
cpu merged 1 commit into
rustls:mainfrom
ArniDagur:fix-keyupdate-clear-error

Conversation

@ArniDagur

@ArniDagur ArniDagur commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

We don't support switching traffic keys, so after a peer rekeys every read fails to decrypt with an opaque EBADMSG. Detect the KeyUpdate handshake message and fail the read with an explicit error instead. NewSessionTicket is still ignored.

This matches Facebook's kTLS implementation's handling of both KeyUpdate and NewSessionTicket: https://github.com/facebookincubator/fizz/blob/7fb7075a65ec9e669a6851669502d549e12f9e0f/fizz/experimental/ktls/AsyncKTLSSocket.cpp#L257-L280

We should implement KeyUpdate in the ktls crate at some point. There is already ongoing work (#62). Until that is complete, it's best to return an explicit error.

@ArniDagur

Copy link
Copy Markdown
Contributor Author

@djc can you also take a look

@ArniDagur

Copy link
Copy Markdown
Contributor Author

Tell me if anything needs to happen on my end here.

I'd like to do a followup PR in terms of implementing KeyUpdates, and this is a prerequisite.

@cpu cpu left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tell me if anything needs to happen on my end here.

Please be patient before following up again for reviews. Four days isn't very long, especially for this repo that gets less maintainer attention given its niche status.

Comment thread ktls/src/ktls_stream.rs
Comment thread ktls/src/ktls_stream.rs
@ArniDagur
ArniDagur force-pushed the fix-keyupdate-clear-error branch from 3428ff4 to db35997 Compare August 7, 2026 17:06
@ArniDagur

Copy link
Copy Markdown
Contributor Author

Please be patient before following up again for reviews. Four days isn't very long, especially for this repo that gets less maintainer attention given its niche status.

Understood. Thank you for the review and I'm sorry.

@cpu

cpu commented Aug 7, 2026

Copy link
Copy Markdown
Member

Can you squash your commits into one? I will merge afterwards and if djc has any additional feedback we can iterate as follow-up.

The kernel cannot switch traffic keys, so after a peer rekeys every
read fails to decrypt with an opaque `EBADMSG`. Detect the KeyUpdate
handshake message and fail the read with an explicit error instead.
NewSessionTicket is still ignored.

This matches Facebook's kTLS implementation:
https://github.com/facebookincubator/fizz/blob/7fb7075a65ec9e669a6851669502d549e12f9e0f/fizz/experimental/ktls/AsyncKTLSSocket.cpp#L257-L280

We should implement `KeyUpdate` in the `ktls` crate at some point.
There is already ongoing work (rustls#62).
Until that is complete, it's best to return an explicit error.
@ArniDagur
ArniDagur force-pushed the fix-keyupdate-clear-error branch from 131dd43 to 54d5e07 Compare August 7, 2026 17:17
@ArniDagur

Copy link
Copy Markdown
Contributor Author

I squashed the commits

@cpu
cpu added this pull request to the merge queue Aug 7, 2026
Merged via the queue into rustls:main with commit 5e3c7d6 Aug 7, 2026
2 checks passed
@ArniDagur

ArniDagur commented Aug 7, 2026

Copy link
Copy Markdown
Contributor Author

I'll let these changes run in production for a while.

If everything looks good, I think it could be a good time to make a v6.0.3 release in maybe 2 weeks or so?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants