Open Bug 339921 Opened 19 years ago Updated 9 months ago

Coverity 410, NULL ptr crash in certdb_SaveSingleProfile

Categories

(NSS :: Libraries, defect, P3)

3.11.1

Tracking

(Not tracked)

People

(Reporter: nelson, Assigned: rrelyea)

References

(Blocks 2 open bugs, )

Details

(Keywords: coverity, crash, Whiteboard: [CID 410])

Attachments

(1 file)

In function certdb_SaveSingleProfile in file nss/lib/certdb/stanpcertdb.c there are lots of ways to reach this statement: 808 stanProfile->profileTime = nssItem_Create(arena, 809 NULL, 810 profileTime->len, 811 profileTime->data); with profileTime being NULL, and hence crashing here. It appears to me that the very next statement has an equal probability of crashing in the same way, due to NULL emailProfile. 812 stanProfile->profileData = nssItem_Create(arena, 813 NULL, 814 emailProfile->len, 815 emailProfile->data); Figuring out all the right checks, to eliminate all the crashing paths, without breaking NSS code that depends on this function, will be a real head scratcher, I think.
Assignee: nobody → rrelyea
Priority: -- → P2
Target Milestone: --- → 3.11.2
Whiteboard: [CID 410]
Retargetting all P2s to 3.11.3 .
Target Milestone: 3.11.2 → 3.11.3
Severity: normal → critical
Keywords: crash
Attached patch Patch v1Splinter Review
Patch v1. Not sure if this is the correct fix.
Attachment #242781 - Flags: superreview?(nelson)
Attachment #242781 - Flags: review?(rrelyea)
Comment on attachment 242781 [details] [diff] [review] Patch v1 r- So in this code it is permissible to write NULL email and profile times. It's also permissible to write a NULL oldProfileTime. The question because what is the correct semantic for if the crypto context exists. My initial though is the crypto context profile should be destroyed and removed from the list, but more investigation is required.
Attachment #242781 - Flags: review?(rrelyea) → review-
Comment on attachment 242781 [details] [diff] [review] Patch v1 cancelling SR request, since the patch got r-.
Attachment #242781 - Flags: superreview?(nelson)
Target Milestone: 3.11.3 → 3.11.7
3.11.7 is done. Retargeting to 3.11.8 .
Target Milestone: 3.11.7 → 3.11.8
Target Milestone: 3.11.8 → ---
I found this when doing code review on changes to p7decode.c. It seems like this crash will occur in cases where certificate chain verification fails inside of SEC_PKCS7VerifySignature/SEC_PKCS7VerifyDetachedSignature when verifying for an email cert usage, since we still try to write an S/MIME profile, passing in a NULL emailProfile (which will cause a NULL profileTime, I believe). In bug 808224, I will create aa alternative API for verifying PKCS7 signatures in bug that will not deail with S/MIME profile management stuff at all. Then it will be the application's responsibility to save the S/MIME profile using an explicit CERT_SaveSMIMEProfile call. I recommend that Thunderbird switch to use the API I add in bug 808224. I'm not sure how to change SEC_PKCS7VerifySignature/SEC_PKCS7VerifyDetachedSignature and the code it calls to deal with S/MIME profiles to be safe and still have the same semantics. And, also, it is unclear to me why we try to save an S/MIME profile at all if signature and/or certificate chain validation fails in these functions.
Severity: critical → S2
Severity: S2 → S3
Priority: P2 → P3
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: