When length - 32 Goes Negative: A Small Check, Real Memory Bug in
In wolfSSL's TLS 1.3 session ticket handling, SetTicket() only checked that the ticket length was greater than zero before computing a pointer as ticket + length - 32. A ticket shorter than 32 bytes made that pointer point before the buffer, causing an out-of-bounds read of nearby heap memory.
While looking at the TLS 1.3 session ticket handling in wolfSSL, I found a small boundary issue inside SetTicket() in src/internal.c. At first glance, it looks harmless.
The full write-up lives on its author's site
It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
How it worked
Root cause
The length check only required the ticket to be non-empty, not to be at least the 32-byte ID length subtracted in the pointer arithmetic, so the subtraction could go negative.
Impact
An attacker supplying a ticket shorter than 32 bytes could cause the library to read memory before the ticket buffer, potentially exposing other session data, heap metadata or sensitive material, though the text does not claim a guaranteed crash or a demonstrated leak.
What the attacker needed
Ability to supply a session ticket; ticket shorter than 32 bytes
The fix
The check was changed to require the length to be at least the 32-byte ID length, so the subtraction can no longer go negative; the text presents this as the patch.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
A program stores data in a block of memory and keeps a pointer to where that block starts. This code worked out a position by subtracting 32 from the ticket's length, but only checked the length was above zero, so a short ticket pushed the pointer to before the start of the block. Reading there returns whatever else happens to sit in memory, which the program was never meant to see.
What is Memory corruption?
Native code reads or writes memory it should not: overflows, use-after-free, type confusion. The core of browser, kernel and parser bugs.