Skip to content

ext/openssl: Defer pkcs7/cms verify output writes until verification succeeds - #23651

Open
iliaal wants to merge 1 commit into
php:PHP-8.4from
iliaal:fix/openssl-ss004-pre-verify-truncation
Open

ext/openssl: Defer pkcs7/cms verify output writes until verification succeeds#23651
iliaal wants to merge 1 commit into
php:PHP-8.4from
iliaal:fix/openssl-ss004-pre-verify-truncation

Conversation

@iliaal

@iliaal iliaal commented Sep 10, 2026

Copy link
Copy Markdown
Member

openssl_pkcs7_verify() and openssl_cms_verify() opened the output paths in write mode before verification, emptying existing files on failure. Verified content is buffered in memory and written only on success; the extra PKCS7/CMS output file is created only in that same success branch.

…succeeds

openssl_pkcs7_verify() and openssl_cms_verify() opened the content and
p7b output paths in write mode before verify, emptying existing files
when verification failed. Buffer verified content in a memory BIO and
write it only on success; open the p7b path only in that same success
branch. Sibling audit: both verify functions shared the same early-open
pattern; sign/encrypt paths already write after success.
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