Skip to content

openssl: Fix checks on BIO_get_mem_ptr() - #20998

Merged
ndossche merged 1 commit into
php:masterfrom
ndossche:clesss-4
Aug 3, 2026
Merged

openssl: Fix checks on BIO_get_mem_ptr()#20998
ndossche merged 1 commit into
php:masterfrom
ndossche:clesss-4

Conversation

@ndossche

Copy link
Copy Markdown
Member

If the call fails, then the pointer remains uninitialized, and this triggers undefined behaviour or the reading of a dangling pointer. In my own tests this came out as a UAF. However, it seems not exploitable by an attacker as failure should be not controllable.

It's worth pointing out that OpenSSL checks the return value in its own code that calls this function as well [1].

[1] https://github.com/openssl/openssl/blob/b2ecef451ccede07366023da4553f113f6e4fe71/apps/lib/apps.c#L3307-L3311

This was found by a hybrid static-dynamic analyser that looks for inconsistent handling of error checks in bindings.

@bukka

bukka commented Apr 3, 2026

Copy link
Copy Markdown
Member

This should be master only as it cannot fail in reality.

@ndossche
ndossche changed the base branch from PHP-8.4 to master April 3, 2026 19:11
@ndossche

ndossche commented Apr 3, 2026

Copy link
Copy Markdown
Member Author

Ok rebased for master

If the call fails, then the pointer remains uninitialized, and this
triggers undefined behaviour or the reading of a dangling pointer.
In my own tests this came out as a UAF. However, it seems not
exploitable by an attacker as failure should be not controllable.

It's worth pointing out that OpenSSL checks the return value in its own
code that calls this function as well [1].

[1] https://github.com/openssl/openssl/blob/b2ecef451ccede07366023da4553f113f6e4fe71/apps/lib/apps.c#L3307-L3311
@ndossche
ndossche merged commit 9d7480e into php:master Aug 3, 2026
18 checks passed
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.

4 participants