Skip to content

openssl: Fix checks on BIO_get_mem_ptr()#20998

Open
ndossche wants to merge 1 commit intophp:masterfrom
ndossche:clesss-4
Open

openssl: Fix checks on BIO_get_mem_ptr()#20998
ndossche wants to merge 1 commit intophp: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
Copy link
Copy Markdown
Member

bukka commented Apr 3, 2026

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

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 changed the base branch from PHP-8.4 to master April 3, 2026 19:11
@ndossche
Copy link
Copy Markdown
Member Author

ndossche commented Apr 3, 2026

Ok rebased for master

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.

3 participants