Add bounds check on wolfSSL_X509_notBefore and wolfSSL_X509_notAfter#10071
Add bounds check on wolfSSL_X509_notBefore and wolfSSL_X509_notAfter#10071padelsbach wants to merge 2 commits intowolfSSL:masterfrom
Conversation
|
jenkins retest this please |
GitHub PR Comment for #10071
Hi, thank you for working on this fix. The bounds check in the getter functions is a good first step and prevents the immediate overflow. However, I found several gaps in the current patch that should be addressed before merging: 1. Root cause not fixed (
|
| Location | Status |
|---|---|
| Getter bounds check (this PR) | Fixed |
| Root cause in CopyDecodedToX509 | Not fixed |
| Root cause in attribute cert path | Not fixed |
| Setter validation | Not fixed |
| NULL safety for callers | Not addressed |
The getter check is defense-in-depth — good to have, but the root cause at the data source should also be fixed to prevent the struct from entering an invalid state.
6fb048f to
c51adf7
Compare
|
Hi @programsurf, thanks for the additional comments. These are beyond the scope of the original 2 byte overflow described in the support ticket. However, I've expanded this commit to address most of the additional concerns. I did not address the NULL return (item 3). |
84bb1f0 to
d5323a0
Compare
PR #10071 Review — Second Round (post force-push d5323a0)Thanks for the updated commit — you've addressed items 1, 2, and 4 from my earlier comment. I see you decided not to address item 3 (NULL return safety), which is fair. Here's what I found looking at the new code: What's fixedThe new Remaining issue: setter/getter bounds mismatchThere's still an off-by-2 inconsistency between the setter and getter that will cause confusing behavior. The setter checks (x509.c ~line 16075): if (t->length < 0 || t->length > (int)sizeof(x509->notAfter.data)) {
But the getter checks (x509.c ~line 4449): if (x509->notAfter.length > (int)sizeof(x509->notAfterData) - 2) {
And So if someone calls The fix is straightforward — the setter should use the same limit: if (t->length < 0 || t->length > (int)sizeof(x509->notAfter.data) - 2) {Same for Test gap: boundary test doesn't cover the right code pathThe boundary test at crafted_time.length = CTC_DATE_SIZE; // 32
ExpectIntEQ(wolfSSL_X509_set_notAfter(x, &crafted_time), WOLFSSL_SUCCESS);
ExpectNotNull(retrieved = X509_get_notAfter(x));This passes because NULL return — acknowledgedYou declined to address item 3 (NULL safety for callers), which is fair — it's a design decision. Just noting that existing callers in apps like httpd or haproxy may not expect NULL from Minor notes
TL;DR
|
06e01ca to
2bd4fdb
Compare
|
jenkins retest this please |
2bd4fdb to
41b969b
Compare
Description
Fixes zd 21416
Testing
How did you test?
Checklist