Skip to content

ext/openssl: fix use after free when callbacks close streams - #24065

Open
DanielEScherzer wants to merge 5 commits into
php:PHP-8.6from
DanielEScherzer:openssl-stream-no-close
Open

DanielEScherzer wants to merge 5 commits into
php:PHP-8.6from
DanielEScherzer:openssl-stream-no-close

Conversation

@DanielEScherzer

Copy link
Copy Markdown
Member

See individual commits for details

@bukka bukka 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.

It looks good, just one place might be missing.

Comment thread ext/openssl/xp_ssl.c
const unsigned char *session_id = SSL_SESSION_get_id(session, &session_id_len);

zval args[2];

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.

shouldn't it be added here (php_openssl_session_remove_cb) as well?

@bukka bukka 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.

It looks good, just one place might be missing.

@bukka

bukka commented Oct 4, 2026

Copy link
Copy Markdown
Member

I wonder if we should also check for exception in php_openssl_handshake_early_data . Not exactly related but just something that I noticed when checking this.

@DanielEScherzer

Copy link
Copy Markdown
Member Author

I wasn't able to trigger an error with session_remove_cb closing the stream, maybe because at that point it is not going to be used again?

For exceptions in the early data callback, I also didn't get any issues, tested with close_in_early_data_cb_UAF.phpt having throw new Exception('test'); instead of fclose($stream);

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