Skip to content

openssl: Fix heap buffer overflow in TLS PSK callbacks - #25134

Closed
bukka wants to merge 1 commit into
php:PHP-8.6from
bukka:openssl_tls_session_psk_overflow
Closed

bukka wants to merge 1 commit into
php:PHP-8.6from
bukka:openssl_tls_session_psk_overflow

Conversation

@bukka

@bukka bukka commented Nov 1, 2026

Copy link
Copy Markdown
Member

The PSK callbacks copied the user-returned identity and key into fixed-size buffers without checking their length. The constructor of Openssl\Psk enforces the limits, but unserialize() bypasses it, so an oversized string overflowed the buffer. Bound each length to its buffer before copying.

@bukka

bukka commented Nov 1, 2026

Copy link
Copy Markdown
Member Author

This was reported by @TristanInSec as a security issue but it is impacting just PHP-8.6 pre-release so it's handled as a normal bug.

@bukka
bukka changed the base branch from master to PHP-8.6 November 1, 2026 18:17

@Girgias Girgias left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Should we just throw value errors instead?

The PSK callbacks copied the user-returned identity and key into
fixed-size buffers without checking their length. The constructor of
Openssl\Psk enforces the limits, but unserialize() bypasses it, so an
oversized string overflowed the buffer. Bound each length to its buffer
before copying.

Co-authored-by: Tristan Madani <1075304+TristanInSec@users.noreply.github.com>
@bukka
bukka force-pushed the openssl_tls_session_psk_overflow branch from 8522cc6 to bf312fe Compare November 1, 2026 19:36
@bukka

bukka commented Nov 1, 2026

Copy link
Copy Markdown
Member Author

Should we just throw value errors instead?

Yeah good point. Done.

@bukka bukka closed this in 4f2bee4 Nov 1, 2026
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.

2 participants