Skip to content

tls: store the TLS 1.3 NewSessionTicket sent by TLSServerAutomaton - #5308

Open
Eapp1e wants to merge 1 commit into
secdev:masterfrom
Eapp1e:fix/tls13-server-session-ticket-file
Open

Eapp1e wants to merge 1 commit into
secdev:masterfrom
Eapp1e:fix/tls13-server-session-ticket-file

Conversation

@Eapp1e

@Eapp1e Eapp1e commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

TLSServerAutomaton never writes the session tickets it sends when session_ticket_file is set, so a later PSK resumption has no ticket to offer.

TLS 1.3 NewSessionTicket is a post-handshake message: with post_handshake set, _TLSHandshake.tls_session_update appends it to post_handshake_messages and not to handshake_messages_parsed. should_send_ServerData looks the message up in handshake_messages_parsed after flush_records(), so save_ticket() is never reached and the file stays empty.

Reproducer:

from scapy.layers.tls.automaton_cli import TLSClientAutomaton
from scapy.layers.tls.automaton_srv import TLSServerAutomaton
from scapy.layers.tls.handshake import TLS13ClientHello

srv = TLSServerAutomaton(mycert=cert, mykey=key, handle_session_ticket=True,
                         session_ticket_file="/tmp/tickets")
# serve in a thread, then:
TLSClientAutomaton(client_hello=TLS13ClientHello(ciphers=0x1301),
                   data=[b"ping", b"wait", b"quit"], version="tls13").run()

/tmp/tickets does not exist afterwards.

Suggestion: collect the TLS13NewSessionTicket messages of buffer_out before flush_records() builds them, and call save_ticket() on those references afterwards.

Fixes #4682.

This message was written with the help of AI (DeepSeek V4.1 Flash).

should_send_ServerData() retrieved the ticket from handshake_messages_parsed
after flush_records(). A TLS 1.3 NewSessionTicket is a post-handshake message,
so it is appended to post_handshake_messages instead, and save_ticket() was
never called: the session_ticket_file stayed empty and a PSK resumption had
nothing to offer (secdev#4682).

Collect the TLS13NewSessionTicket messages of buffer_out before
flush_records() builds them, and save those references afterwards.

AI-Assisted: yes (DeepSeek V4.1 Flash)

Fixes secdev#4682
@codecov

codecov Bot commented Nov 23, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 80.64%. Comparing base (a11a9b6) to head (dee76c1).

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #5308      +/-   ##
==========================================
+ Coverage   80.61%   80.64%   +0.02%     
==========================================
  Files         375      375              
  Lines       98849    98844       -5     
==========================================
+ Hits        79688    79708      +20     
+ Misses      19161    19136      -25     
Files with missing lines Coverage Δ
scapy/layers/tls/automaton_srv.py 74.60% <100.00%> (+2.03%) ⬆️

... and 4 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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.

TLSServerAutomaton in tls1.3 of Scapy v2.6.1 cannot save_ticket(TLS13NewSessionTicket)

1 participant