Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@n13l
Copy link
Contributor

@n13l n13l commented Nov 7, 2025

CRL: Enforce proper handling of ASN1_DATE validation results

ASN1 correctly validates date fields and reports errors to the error stack. Previously, even when validation failed, a CRL object was still returned and could, in some cases, be successfully used for verification.

This change fixes that behavior by ensuring validation errors are properly handled and invalid CRLs are rejected.

Fixes #27445

The change in behavior can also be observed in the command line, but unfortunately, in this case, only the top error in the stack is visible. If it also displayed the correct ASN1_R_GENERALIZEDTIME_IS_TOO_SHORT, it could be useful for the user.

openssl crl -in crl_revoked_inv_date_utc_.pem -noout -text
Could not find CRL from crl_revoked_inv_date_utc_.pem
4007BC5A4A700000:error:1608010C:STORE routines:ossl_store_handle_load_result:unsupported:crypto/store/store_result.c:162:provider=default

@n13l n13l added branch: master Merge to master branch approval: review pending This pull request needs review by a committer triaged: bug The issue/pr is/fixes a bug backlog fix The issue was closed as part of the backlog reduction initiative. labels Nov 7, 2025
@n13l n13l requested review from mattcaswell, t8m and vdukhovni November 8, 2025 10:11
@n13l n13l changed the title CRL: Added date and time validation during parsing CRL: Enforce proper handling of ASN1_DATE validation results Nov 8, 2025
@n13l n13l force-pushed the rfc_5280_crl_incorrect_invalidity_date branch 3 times, most recently from b2e49fc to 2a23d05 Compare November 9, 2025 12:52
Copy link
Contributor

@shahsb shahsb left a comment

Choose a reason for hiding this comment

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

This targets the CRL path. Do you suspect this issue might exist for other object types that we should also look at?

* lastUpdate and treat missing or invalid values as a failure.
*/
if (crl->crl.lastUpdate == NULL) {
crl->flags |= EXFLAG_INVALID;
Copy link
Contributor

Choose a reason for hiding this comment

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

could you elaborate a little on the potential scenarios where the old behavior of accepting an invalid CRL could have been exploited? Understanding the real-world impact would be really valuable.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This PR primarily addresses invalidityDate; its absence can have specific security and functional impacts during verification. Other time fields in the CRL are also validated, as this check is inexpensive (in case of ASN.1 parser failure, we simply test for NULL). There is some leniency, we can accept UTC where the RFC requires GENERALIZED TIME, but if the time is completely invalid, it makes sense to reject the CRL immediately rather than waiting for further checks during verification.

&& TEST_ptr_null((tss = crl_clear_err_parse(kInvalidDateSS)))
&& TEST_true(err_chk(ERR_LIB_ASN1, ASN1_R_GENERALIZEDTIME_IS_TOO_SHORT))
&& TEST_ptr_null((utc = crl_clear_err_parse(kInvalidDateUTC)))
&& TEST_true(err_chk(ERR_LIB_ASN1, ASN1_R_WRONG_TAG));
Copy link
Contributor

Choose a reason for hiding this comment

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

This change looks great. I was wondering if we could add a few more test cases to cement the behavior? Specifically, testing for a wider variety of malformed date formats (like invalid time zones, bad characters, etc.) might help ensure we've covered all the bases. I can help draft these if that's useful.

Copy link
Member

Choose a reason for hiding this comment

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

This would be a separate effort and PR. If you want to work on such test cases, that would be certainly welcome.

*/
if (nid == NID_invalidity_date) {
if ((inv_date = X509V3_EXT_d2i(ext)) == NULL) {
crl->flags |= EXFLAG_INVALID;
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we consider adding a note about these stricter validations in the CHANGES file or the relevant man pages (like openssl-crl)? It might save some time for users who suddenly find previously accepted CRLs are now being rejected, helping them understand why.

Copy link
Member

@t8m t8m Nov 11, 2025

Choose a reason for hiding this comment

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

Yes, good point. CHANGES.md entry should definitely be added.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good reminder. I still have some other CRL issues in the queue that also relate to error reporting and actually to openssl crl usability, but I was planning to open a PR for that later, once I have a PR ready that fixes the specific problems. There can definitely be a different opinion on this, but my plan was to save time and not touch the shared parts in every CRL PR.

X509_CRL *tmm = NULL, *tss = NULL, *utc = NULL;
int test = 0;

test = TEST_ptr_null((tmm = crl_clear_err_parse(kInvalidDateMM)))
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm curious if you've had a chance to test this with a variety of real-world or fuzzed CRLs to see if the new validation behaves as expected in all edge cases? If there's any area where I could help with validation testing, please let me know.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don’t have anything beyond the existing tests and the new ones I’ve added. There’s definitely room for additional CRLs that would cover the existing use cases and thoroughly cover the cases in the code (coverage).

Copy link
Contributor

@shahsb shahsb left a comment

Choose a reason for hiding this comment

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

Does this user-visible failure change warrant a changelog entry?

@t8m t8m added the tests: present The PR has suitable tests present label Nov 11, 2025
@t8m
Copy link
Member

t8m commented Nov 11, 2025

@n13l Please rebase

@n13l n13l force-pushed the rfc_5280_crl_incorrect_invalidity_date branch 2 times, most recently from db17efc to 9d77f0f Compare November 12, 2025 17:27
ASN1 correctly validates date fields and reports errors to the error
stack. Previously, even when validation failed, a CRL object was still
returned and could, in some cases, be successfully used for
verification.

This change fixes that behavior by ensuring validation errors are
properly handled and invalid CRLs are rejected.

Fixes openssl#27445
@n13l n13l force-pushed the rfc_5280_crl_incorrect_invalidity_date branch from 9b47991 to 1cc03da Compare November 12, 2025 21:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approval: review pending This pull request needs review by a committer backlog fix The issue was closed as part of the backlog reduction initiative. branch: master Merge to master branch tests: present The PR has suitable tests present triaged: bug The issue/pr is/fixes a bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

OpenSSL parsed a CRL file with an incorrect Invalidity Date field value.

3 participants