Skip to content

Conversation

@alex
Copy link
Collaborator

@alex alex commented Nov 6, 2025

The OCSP find_status function was unsound because it treated next_update as always present, even though it's optional per RFC 6960. When absent, the null pointer from FFI was passed to from_ptr which doesn't check for null, causing undefined behavior.

Fixed by using from_const_ptr_opt to safely handle the null case. Added next_update() method returning Option<&Asn1GeneralizedTimeRef> and deprecated the existing field which now contains a sentinel max time value (99991231235959Z) for backwards compatibility.

Fixes #2516

@alex
Copy link
Collaborator Author

alex commented Nov 6, 2025

I don't understand the warning in the MSRV builder. We have an allow(), does that not work on older Rust?

@alex alex force-pushed the claude/fix-ocsp-find-status-011CUqcGFNKeKJitnywzYCna branch from 6aa5292 to 4eafa15 Compare November 6, 2025 00:34
Copy link
Contributor

@botovq botovq left a comment

Choose a reason for hiding this comment

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

The code itself reads fine modulo one thing that could be better if we didn't support ancient library versions.

(I really do not like Claude's overly repetitive and verbose commenting style.)

@alex
Copy link
Collaborator Author

alex commented Nov 6, 2025

You should have seen how bad the comments were before I trimmed them down 🙃. (I'm ultimately accountable for anything in this PR, so really it's better that I think of it as my comments are bad.)

@alex alex force-pushed the claude/fix-ocsp-find-status-011CUqcGFNKeKJitnywzYCna branch from 4eafa15 to bc3c83f Compare November 6, 2025 22:36
The OCSP find_status function was unsound because it treated next_update
as always present, even though it's optional per RFC 6960. When absent,
the null pointer from FFI was passed to from_ptr which doesn't check for
null, causing undefined behavior.

Fixed by using from_const_ptr_opt to safely handle the null case. Added
next_update() method returning Option<&Asn1GeneralizedTimeRef> and
deprecated the existing field which now contains a sentinel max time
value (99991231235959Z) for backwards compatibility.

Fixes rust-openssl#2516
@alex alex force-pushed the claude/fix-ocsp-find-status-011CUqcGFNKeKJitnywzYCna branch from bc3c83f to cc26867 Compare November 6, 2025 22:40
Copy link
Contributor

@botovq botovq left a comment

Choose a reason for hiding this comment

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

Looks much better to me. One suggestion - feel free to ignore.

@alex
Copy link
Collaborator Author

alex commented Nov 6, 2025

I'll plan to do a release with this fix tomorrow.

@alex alex merged commit 395ecca into rust-openssl:master Nov 6, 2025
81 checks passed
@alex alex deleted the claude/fix-ocsp-find-status-011CUqcGFNKeKJitnywzYCna branch November 6, 2025 23:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Potential UB in ocsp::find_status due to unconditional call to Asn1GeneralizedTimeRef::from_ptr on potentially null pointers

3 participants