Closed
Bug 1382994
Opened 8 years ago
Closed 8 years ago
UAF in InitializeNSSWithFallbacks in nsNSSComponent.cpp
Categories
(Core :: Security: PSM, defect, P1)
Tracking
()
RESOLVED
FIXED
mozilla56
People
(Reporter: tbourvon, Assigned: tbourvon, Mentored)
References
Details
(Keywords: regression, sec-audit, Whiteboard: [psm-assigned][adv-main55-][post-critsmash-triage])
Attachments
(1 file)
2.90 KB,
patch
|
keeler
:
review+
ttaubert
:
feedback+
jcristau
:
approval-mozilla-beta+
|
Details | Diff | Splinter Review |
Our WIP static-analysis checker has identified a UAF in InitializeNSSWithFallbacks in nsNSSComponent.cpp on line 1718. It detects the use of pointers owned by temporaries after they are deleted (https://bugzilla.mozilla.org/show_bug.cgi?id=1374024).
> mozilla-central/security/manager/ssl/nsNSSComponent.cpp:1718:65: error: calling `get` on a temporary, potentially allowing use after free of the raw pointer [mozilla-dangling-on-temporary]
> const char* profilePathCStr = PromiseFlatCString(profilePath).get();
> ^
Here |get()| returns a pointer to memory owned by |PromiseFlatCString|, which gets freed as soon as the temporary |PromiseFlatCString| is deleted (i.e. as soon as the assignment is over). |profilePathCStr| now points to freed memory.
Assignee | ||
Comment 1•8 years ago
|
||
This patch fixes the UAF by keeping the temporary alive for the whole scope of the function.
It uses the method suggested in the heading of xpcom/string/nsTPromiseFlatString.h, which is to bind a const ref to the temporary, extending its lifetime to match the one of the reference.
This method copies the |nsCString| object to the stack, but this is a very minor cost and is better than the other solutions (such as duplicating the |const char*| returned by |.get()| or reusing |PromiseFlatCString(...).get()| multiple times at the call sites).
Attachment #8888767 -
Flags: review?(ttaubert)
Comment 2•8 years ago
|
||
Comment on attachment 8888767 [details] [diff] [review]
1382994.patch
Review of attachment 8888767 [details] [diff] [review]:
-----------------------------------------------------------------
LGTM, but I'm not a PSM peer. Let's ask David.
Attachment #8888767 -
Flags: review?(ttaubert)
Attachment #8888767 -
Flags: review?(dkeeler)
Attachment #8888767 -
Flags: feedback+
![]() |
||
Comment 3•8 years ago
|
||
Comment on attachment 8888767 [details] [diff] [review]
1382994.patch
Review of attachment 8888767 [details] [diff] [review]:
-----------------------------------------------------------------
D'oh. Thanks.
For future reference, any bugs in this directory can go in Core :: Security: PSM.
Also, looks like we've got at least a few more instances of this if your analysis hasn't already found them:
https://dxr.mozilla.org/mozilla-central/rev/7d2e89fb92331d7e4296391213c1e63db628e046/modules/libjar/nsJAR.cpp#328
https://dxr.mozilla.org/mozilla-central/rev/7d2e89fb92331d7e4296391213c1e63db628e046/netwerk/mime/nsMIMEHeaderParamImpl.cpp#824
Attachment #8888767 -
Flags: review?(dkeeler) → review+
![]() |
||
Updated•8 years ago
|
Component: Security → Security: PSM
Priority: -- → P1
Whiteboard: [psm-assigned]
Assignee | ||
Comment 4•8 years ago
|
||
(In reply to David Keeler [:keeler] (use needinfo?) from comment #3)
> Comment on attachment 8888767 [details] [diff] [review]
> 1382994.patch
>
> Review of attachment 8888767 [details] [diff] [review]:
> -----------------------------------------------------------------
>
> D'oh. Thanks.
> For future reference, any bugs in this directory can go in Core :: Security:
> PSM.
> Also, looks like we've got at least a few more instances of this if your
> analysis hasn't already found them:
>
> https://dxr.mozilla.org/mozilla-central/rev/
> 7d2e89fb92331d7e4296391213c1e63db628e046/modules/libjar/nsJAR.cpp#328
> https://dxr.mozilla.org/mozilla-central/rev/
> 7d2e89fb92331d7e4296391213c1e63db628e046/netwerk/mime/nsMIMEHeaderParamImpl.
> cpp#824
My analysis found exactly 3 bugs, this one and the two you linked!
Looks like we don't need it after all, we could just ask you to find them...
Comment 5•8 years ago
|
||
This goes back to Fx54 AFAICT. Please request sec-approval on this before landing :)
Blocks: 1337950
Group: core-security → crypto-core-security
status-firefox54:
--- → wontfix
status-firefox55:
--- → affected
status-firefox56:
--- → affected
status-firefox-esr52:
--- → unaffected
tracking-firefox55:
--- → ?
tracking-firefox56:
--- → ?
Version: unspecified → 54 Branch
Updated•8 years ago
|
Flags: needinfo?(tbourvon)
Assignee | ||
Comment 6•8 years ago
|
||
Comment on attachment 8888767 [details] [diff] [review]
1382994.patch
[Security approval request comment]
How easily could an exploit be constructed based on the patch?
UAFs are hard to exploit, but this one is in the middle of NSS initialization where lots of allocations happen, so the risk is definitely increased (and in a critical part of the code).
Do comments in the patch, the check-in comment, or tests included in the patch paint a bulls-eye on the security problem?
Yes.
Which older supported branches are affected by this flaw?
This was introduced in Firefox 54 and affects all later branches.
If not all supported branches, which bug introduced the flaw?
N/A
Do you have backports for the affected branches? If not, how different, hard to create, and risky will they be?
The patch should be easy to backport without too many issues.
How likely is this patch to cause regressions; how much testing does it need?
The fix is fairly straightforward and not very risky, it probably doesn't need testing.
Flags: needinfo?(tbourvon)
Attachment #8888767 -
Flags: sec-approval?
Updated•8 years ago
|
Comment 7•8 years ago
|
||
Calling this a sec-audit and clearing sec-approval (as it doesn't apply to audit bugs). You can check this into trunk but if you think we should take this in Beta and ESR52, a case will need to be made this late in the cycle.
Since this only goes back to 54, a case could be made to take it on 55 though.
Keywords: sec-audit
Comment 8•8 years ago
|
||
https://hg.mozilla.org/integration/mozilla-inbound/rev/5fd23c6134b93c256a2bdca91eacc60b6c43c662
I've confirmed this grafts cleanly Beta. I think we should nominate it for approval since it's UAF and the odds of someone trying to attack it go up now that it's out there. Patch is simple enough anyway.
Flags: needinfo?(tbourvon)
Updated•8 years ago
|
Attachment #8888767 -
Flags: sec-approval?
Assignee | ||
Comment 9•8 years ago
|
||
Comment on attachment 8888767 [details] [diff] [review]
1382994.patch
Approval Request Comment
[Feature/Bug causing the regression]: UAF in InitializeNSSWithFallbacks
[User impact if declined]: users left potentially vulnerable to this security issue
[Is this code covered by automated tests?]: Yes (https://codecov.io/gh/marco-c/gecko-dev/src/master/security/manager/ssl/nsNSSComponent.cpp#L1718)
[Has the fix been verified in Nightly?]: builds but not hand-tested
[Needs manual test from QE? If yes, steps to reproduce]: probably not
[List of other uplifts needed for the feature/fix]: none
[Is the change risky?]: very low risk
[Why is the change risky/not risky?]: small change with a proven method
[String changes made/needed]:
Flags: needinfo?(tbourvon)
Attachment #8888767 -
Flags: approval-mozilla-beta?
Comment 10•8 years ago
|
||
Status: ASSIGNED → RESOLVED
Closed: 8 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla56
Comment 11•8 years ago
|
||
Comment on attachment 8888767 [details] [diff] [review]
1382994.patch
let's get this in 55.0b13, seems safe enough
Attachment #8888767 -
Flags: approval-mozilla-beta? → approval-mozilla-beta+
Comment 12•8 years ago
|
||
uplift |
Updated•8 years ago
|
Whiteboard: [psm-assigned] → [psm-assigned][adv-main55-]
Updated•8 years ago
|
Group: crypto-core-security → core-security-release
Updated•8 years ago
|
Flags: qe-verify-
Whiteboard: [psm-assigned][adv-main55-] → [psm-assigned][adv-main55-][post-critsmash-triage]
Updated•7 years ago
|
Group: core-security-release
Comment 13•6 years ago
|
||
Tristan, it looks like you are the assignee on this bug, but under a different email. Are you still working on this bug? If not, would you please unassign yourself?
Flags: needinfo?(tristanbourvon)
Comment 14•6 years ago
|
||
Sorry for the spurious NI request, missed that this bug had been resolved.
Flags: needinfo?(tristanbourvon)
Updated•6 years ago
|
Keywords: regression
You need to log in
before you can comment on or make changes to this bug.
Description
•