Skip to content
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

qtls: protect the tls.ClientSessionCache implementation with a mutex #4319

Merged
merged 1 commit into from
Feb 9, 2024

Conversation

marten-seemann
Copy link
Member

This prevents a race condition when the underlying ClientSessionCache provided by the application returns the same session ticket for multiple connections. Reusing session tickets is explicitly recommended against by both RFC 8446 and RFC 9001, but it's not forbidden. This fix only benefits applications that compromise their users' privacy by reusing session tickets.

@ainar-g Could you give this PR a try? As a permanent fix, I'd recommend not reusing session tickets though.

This prevents a race condition when the underlying ClientSessionCache
provided by the application returns the same session ticket for multiple
connections. Reusing session tickets is explicitly recommended against
by both RFC 8446 and RFC 9001, but it's not forbidden. This fix only
benefits applications that compromise their users' privacy by reusing
session tickets.
@marten-seemann marten-seemann linked an issue Feb 9, 2024 that may be closed by this pull request
@marten-seemann marten-seemann added this to the v0.42 milestone Feb 9, 2024
Copy link

codecov bot commented Feb 9, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (013949c) 84.15% compared to head (d4660f8) 84.16%.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #4319      +/-   ##
==========================================
+ Coverage   84.15%   84.16%   +0.01%     
==========================================
  Files         150      150              
  Lines       15368    15374       +6     
==========================================
+ Hits        12932    12938       +6     
+ Misses       1938     1937       -1     
- Partials      498      499       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@ainar-g
Copy link

ainar-g commented Feb 9, 2024

As mentioned in #4318, we weren't able to reproduce the race in our code reliably yet. As far as I can see, the original code is not explicitly reusing any session tickets. It essentially is trying to establish both an HTTP/2 and an HTTP/3 connection to the same endpoint at the same time to see which protocol is faster.

The code in the PR looks good to me, but I wonder if I should file an issue about the unclear documentation in the Go repo?

@marten-seemann
Copy link
Member Author

Not sure what documentation you want to improve. Warn against the reuse of session tickets? That sounds like a worthwhile change.

@marten-seemann marten-seemann merged commit 284996e into master Feb 9, 2024
34 checks passed
mgjeong pushed a commit to mgjeong/quic-go that referenced this pull request Feb 13, 2024
…uic-go#4319)

This prevents a race condition when the underlying ClientSessionCache
provided by the application returns the same session ticket for multiple
connections. Reusing session tickets is explicitly recommended against
by both RFC 8446 and RFC 9001, but it's not forbidden. This fix only
benefits applications that compromise their users' privacy by reusing
session tickets.
@marten-seemann marten-seemann deleted the session-cache-mutex branch February 18, 2024 04:47
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.

Possible data race in qtls.clientSessionCache
2 participants