Skip to content

Fix global TLS ticket key use for certificate contexts - #13677

Merged
bneradt merged 1 commit into
apache:masterfrom
RajaMuhammadAwais:fix-8734-global-ticket-key
Sep 17, 2026
Merged

bneradt merged 1 commit into
apache:masterfrom
RajaMuhammadAwais:fix-8734-global-ticket-key

Conversation

@RajaMuhammadAwais

@RajaMuhammadAwais RajaMuhammadAwais commented Sep 14, 2026 •

Copy link
Copy Markdown
Contributor

Fix TLS Session Ticket Key Divergence Between Certificate Contexts

Related Issue

Fixes apache/trafficserver#8734.

Summary

Traffic Server can use different TLS session-ticket encryption keys depending on which certificate context handles a connection. This makes session-ticket resumption inconsistent across SNI/IP certificate contexts and can cause a deployment that shares Session Ticket Encryption Keys (STEKs) to split into groups of servers that can resume tickets only within their own group.

This change makes default certificate contexts use the globally managed TLS session-ticket key configuration instead of generating and retaining an independent random key block for every certificate context.

Problem

The TLS session-ticket callback selects its key block as follows:

  1. It looks up the certificate context associated with the local endpoint.
  2. If that context has a key block, it uses the context-specific key block.
  3. Otherwise, it falls back to SSLTicketKeyConfig::default_global_keyblock.

The certificate-context loader was creating a new random ticket-key block for every SNI/IP certificate context while enabling session tickets. These context-specific key blocks were stored in SSLCertContext::keyblock.

At the same time, the TSSslTicketKeyUpdate() API updates the global SSLTicketKeyConfig key block. It does not replace the independently stored key blocks attached to existing certificate contexts.

Therefore, a ticket-key update could succeed globally while connections selecting certificate contexts continued to encrypt and decrypt tickets with different, locally generated keys.

In a multi-server deployment using shared STEKs, this explains the issue's observed behavior: servers could resume sessions within subsets of the deployment but not across all servers.

Root Cause

The defect is the mismatch between these two ownership models:

  • Key updates: Global, through TSSslTicketKeyUpdate() and SSLTicketKeyConfig::default_global_keyblock.
  • Default certificate contexts: Independent random key blocks created during SSL context construction.

Because the context-specific key blocks were not updated by the global API, the API and the TLS ticket callback could operate on different key material.

What Changed

This patch changes ssl_context_enable_tickets() to perform only the SSL_CTX ticket-callback setup and ticket-option enablement. It no longer allocates a random key block during certificate-context construction.

When session tickets are enabled:

  • The TLS ticket callback is registered on the SSL_CTX.
  • TLS tickets remain enabled.
  • The default SSLCertContext is stored without a private ticket key block.
  • The callback consequently uses SSLTicketKeyConfig::default_global_keyblock.
  • Calls to TSSslTicketKeyUpdate() now affect all default SNI/IP certificate contexts consistently.

The change also removes the ticket-renewal metric increment that was previously performed once for each certificate context during context construction. Renewal metrics are now left to the actual global ticket-key configuration/update path.

Why This Is Safe

This preserves the existing global ticket-key behavior:

  • The global ticket key is still loaded/generated by SSLTicketKeyConfig.
  • Explicit ticket-key updates through TSSslTicketKeyUpdate() continue to replace the global key configuration.
  • The session-ticket callback remains registered on each SSL context.
  • Session tickets remain disabled when the relevant session-ticket configuration disables them.
  • Builds where TLS session-ticket support is unavailable retain the existing no-op success behavior.

The patch does not change:

  • Ticket format
  • Cryptographic algorithms
  • Key size
  • Key rotation order
  • OpenSSL callback behavior
  • TLS protocol negotiation

Files Changed

  • src/iocore/net/SSLUtils.cc

Validation Performed

The following checks were completed on the fork branch:

  • Configured Traffic Server with CMake and Ninja.

  • Built against OpenSSL 3.0.13.

  • Built the main traffic_server target successfully:

    [417/417] Linking CXX executable src/traffic_server/traffic_server
    

@bneradt

bneradt commented Sep 14, 2026

Copy link
Copy Markdown
Contributor

[approve ci]

@bryancall
bryancall requested a review from JosiahWI September 14, 2026 21:23

@JosiahWI JosiahWI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The code mostly looks good. I'm not very familiar with this feature. Why are separate certificate contexts stored per IP? Is there data other than the key block that can differ between contexts in ATS, or can the key block change anywhere else?

Comment thread src/iocore/net/SSLUtils.cc Resolved
@RajaMuhammadAwais
RajaMuhammadAwais force-pushed the fix-8734-global-ticket-key branch from fa40b9f to 530bb7a Compare September 15, 2026 15:12

@JosiahWI JosiahWI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Excellent work, thank you!

@bneradt
bneradt merged commit 4025353 into apache:master Sep 17, 2026
14 checks passed
bneradt added a commit to bneradt/trafficserver that referenced this pull request Sep 25, 2026
Since apache#13677, every certificate context protects its session tickets
with the global ticket keys. For a client that sends no SNI, the
certificate is chosen by destination address, so a ticket issued on one
address now resumes on another address serving a different certificate,
and the client is never shown that certificate. The per-context random
keys that apache#13677 removed were the only thing keeping those tickets
apart.

This patch derives the ticket key names, HMAC secrets and AES keys for
an address with its own certificate context from the global keys and a
digest of that context's certificate. A ticket from another certificate
then matches no key and the client falls back to a full handshake,
which ATS now records as such. Servers sharing the ticket key file and
serving the same certificate derive the same keys, so they keep
resuming each other's tickets as apache#13677 intended. Addresses without a
context of their own use the global keys as before.

On a PROXY protocol port the certificate is chosen by the PROXY
destination address, so the ticket keys now follow that address too. A
context with no certificate to bind the keys to neither issues nor
accepts tickets, which a new counter and a one-time warning report. The
unused per-context keyblock is removed.

Fixes: apache#13735

Co-Authored-By: Claude Opus 5.5 <[email protected]>
bneradt added a commit to bneradt/trafficserver that referenced this pull request Sep 25, 2026
Since apache#13677, every certificate context protects its session tickets
with the global ticket keys. For a client that sends no SNI, the
certificate is chosen by destination address, so a ticket issued on one
address now resumes on another address serving a different certificate,
and the client is never shown that certificate. The per-context random
keys that apache#13677 removed were the only thing keeping those tickets
apart.

This patch derives the ticket key names, HMAC secrets and AES keys for
an address with its own certificate context from the global keys and a
digest of that context's certificate. A ticket from another certificate
then matches no key and the client falls back to a full handshake,
which ATS now records as such. Servers sharing the ticket key file and
serving the same certificate derive the same keys, so they keep
resuming each other's tickets as apache#13677 intended. Addresses without a
context of their own use the global keys as before.

On a PROXY protocol port the certificate is chosen by the PROXY
destination address, so the ticket keys now follow that address too,
which also stops an IPv6 PROXY destination being truncated before the
certificate lookup. A tunnel entry has no certificate by design and
keeps the global keys. Any other context whose keys cannot be bound to
a certificate neither issues nor accepts tickets, which a new counter
and a throttled warning report. The unused per-context keyblock is
removed.

Fixes: apache#13735

Co-Authored-By: Claude Opus 5.5 <[email protected]>
bneradt added a commit that referenced this pull request Sep 28, 2026
Since #13677, every certificate context protects its session tickets
with the global ticket keys. For a client that sends no SNI, the
certificate is chosen by destination address, so a ticket issued on one
address now resumes on another address serving a different certificate,
and the client is never shown that certificate. The per-context random
keys that #13677 removed were the only thing keeping those tickets
apart.

This patch derives the ticket key names, HMAC secrets and AES keys for
an address with its own certificate context from the global keys and a
digest of that context's certificate. A ticket from another certificate
then matches no key and the client falls back to a full handshake,
which ATS now records as such. Servers sharing the ticket key file and
serving the same certificate derive the same keys, so they keep
resuming each other's tickets as #13677 intended. Addresses without a
context of their own use the global keys as before.

On a PROXY protocol port the certificate is chosen by the PROXY
destination address, so the ticket keys now follow that address too,
which also stops an IPv6 PROXY destination being truncated before the
certificate lookup. A tunnel entry has no certificate by design and
keeps the global keys. Any other context whose keys cannot be bound to
a certificate neither issues nor accepts tickets, which a new counter
and a throttled warning report. The unused per-context keyblock is
removed.

Fixes: #13735

Co-authored-by: Claude Opus 5.5 <[email protected]>
@github-project-automation github-project-automation Bot moved this to For v10.2.1 in ATS v10.2.x Sep 28, 2026
cmcfarlen pushed a commit to cmcfarlen/trafficserver that referenced this pull request Oct 1, 2026
Since apache#13677, every certificate context protects its session tickets
with the global ticket keys. For a client that sends no SNI, the
certificate is chosen by destination address, so a ticket issued on one
address now resumes on another address serving a different certificate,
and the client is never shown that certificate. The per-context random
keys that apache#13677 removed were the only thing keeping those tickets
apart.

This patch derives the ticket key names, HMAC secrets and AES keys for
an address with its own certificate context from the global keys and a
digest of that context's certificate. A ticket from another certificate
then matches no key and the client falls back to a full handshake,
which ATS now records as such. Servers sharing the ticket key file and
serving the same certificate derive the same keys, so they keep
resuming each other's tickets as apache#13677 intended. Addresses without a
context of their own use the global keys as before.

On a PROXY protocol port the certificate is chosen by the PROXY
destination address, so the ticket keys now follow that address too,
which also stops an IPv6 PROXY destination being truncated before the
certificate lookup. A tunnel entry has no certificate by design and
keeps the global keys. Any other context whose keys cannot be bound to
a certificate neither issues nor accepts tickets, which a new counter
and a throttled warning report. The unused per-context keyblock is
removed.

Fixes: apache#13735

Co-authored-by: Claude Opus 5.5 <[email protected]>
(cherry picked from commit ee427db)
cmcfarlen pushed a commit that referenced this pull request Oct 1, 2026
Traffic Server can use different TLS session-ticket encryption keys depending on which certificate context handles a connection. This makes session-ticket resumption inconsistent across SNI/IP certificate contexts and can cause a deployment that shares Session Ticket Encryption Keys (STEKs) to split into groups of servers that can resume tickets only within their own group.

This change makes default certificate contexts use the globally managed TLS session-ticket key configuration instead of generating and retaining an independent random key block for every certificate context.

(cherry picked from commit 4025353)
@cmcfarlen cmcfarlen modified the milestones: 11.0.0, 10.2.1 Oct 1, 2026
@cmcfarlen cmcfarlen moved this from For v10.2.1 to Picked v10.2.1 in ATS v10.2.x Oct 1, 2026
@cmcfarlen

Copy link
Copy Markdown
Contributor

Cherry-picked to the 10.2.x branch as b9792e5 for the 10.2.1 release.

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

Projects

Status: Picked v10.2.1

Development

Successfully merging this pull request may close these issues.

TLS session ticket get out of sync between servers

5 participants