Skip to content

ext/openssl: Fix shared SSL_CTX callbacks reading a freed session stream - #25211

Closed
iliaal wants to merge 1 commit into
php:PHP-8.6from
iliaal:fix/openssl-session-alpn-uaf
Closed

iliaal wants to merge 1 commit into
php:PHP-8.6from
iliaal:fix/openssl-session-alpn-uaf

Conversation

@iliaal

@iliaal iliaal commented Nov 5, 2026 •

Copy link
Copy Markdown
Member

Since b1242c3, a server stream seeded from a session stream shares the parent's SSL_CTX, whose ALPN select callback (and, on Windows without a CA file, certificate verify callback) was registered with the parent's stream. If the parent is closed before the child's handshake, both read freed memory and the child negotiates no ALPN protocol. Look up the stream from the handshake's SSL instead, and give the child its own copy of the protocol list. Only 8.6 is affected

Since b1242c3 a server stream seeded from a session stream shares the
parent's SSL_CTX. Two callbacks on that context were registered with the
parent's stream as their argument: the ALPN select callback and, on Windows
without a CA file, the certificate verify callback. Closing the parent
before the child completed its handshake left them reading freed memory, and
the child silently negotiated no ALPN protocol. Look up the handshake's own
stream from the SSL ex_data, as verify_callback and the SNI callback do, and
give the child its own copy of the ALPN protocol list.
@iliaal
iliaal requested a review from bukka as a code owner November 5, 2026 15:00
@bukka bukka closed this in 12631df Nov 11, 2026
bukka pushed a commit that referenced this pull request Nov 11, 2026
Since b1242c3 a server stream seeded from a session stream shares the
parent's SSL_CTX. Two callbacks on that context were registered with the
parent's stream as their argument: the ALPN select callback and, on Windows
without a CA file, the certificate verify callback. Closing the parent
before the child completed its handshake left them reading freed memory, and
the child silently negotiated no ALPN protocol. Look up the handshake's own
stream from the SSL ex_data, as verify_callback and the SNI callback do, and
give the child its own copy of the ALPN protocol list.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant