Skip to content

Fix GH-16433: Large values for openssl_csr_sign() $days overflow #16437

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from

Conversation

cmb69
Copy link
Member

@cmb69 cmb69 commented Oct 14, 2024

The offset_sec parameter of X509_gmtime_adj() expects a long, but the $days parameter of openssl_csr_sign() a zend_long. We must avoid signed integer overflow (UB), but also must not silently truncate. Thus we check the given $days for the permissible range, and bail out otherwise.


Note that the lower bound (0) is somewhat arbitrary; we could allow values >= LONG_MIN / 86400. I don't know if that makes sense, though (maybe for testing purposes?)

Also note that I've used E_WARNING for consistency with the rest, but that should probably propagated to a ValueError.

The `offset_sec` parameter of `X509_gmtime_adj()` expects a `long`, but
the `$days` parameter of `openssl_csr_sign()` a `zend_long`.  We must
avoid signed integer overflow (UB), but also must not silently truncate.
Thus we check the given `$days` for the permissible range, and bail out
otherwise.
@cmb69 cmb69 requested a review from bukka as a code owner October 14, 2024 13:51
@cmb69 cmb69 linked an issue Oct 14, 2024 that may be closed by this pull request
Copy link
Member

@devnexen devnexen left a comment

Choose a reason for hiding this comment

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

makes sense to me

@cmb69 cmb69 closed this in 2bdf2f9 Oct 16, 2024
@cmb69 cmb69 deleted the cmb/gh16433 branch October 16, 2024 09:12
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.

Large values for openssl_csr_sign() $days overflow
3 participants