Closed Bug 1513519 Opened 7 years ago Closed 5 years ago

Crash in nsHostResolver::ResolveHost

Categories

(Core :: Networking: DNS, defect, P2)

Unspecified
Android
defect

Tracking

()

RESOLVED FIXED
88 Branch
Tracking Status
firefox-esr60 --- wontfix
firefox-esr68 - wontfix
firefox-esr78 87+ fixed
firefox64 --- wontfix
firefox65 --- wontfix
firefox66 + wontfix
firefox67 --- wontfix
firefox68 --- wontfix
firefox69 --- wontfix
firefox70 --- wontfix
firefox71 --- wontfix
firefox86 --- wontfix
firefox87 + fixed
firefox88 + fixed

People

(Reporter: julienw, Assigned: valentin)

References

Details

(4 keywords, Whiteboard: [necko-triaged][post-critsmash-triage][sec-survey][adv-main87+r][adv-esr78.9+r])

Crash Data

Attachments

(1 file)

This bug was filed from the Socorro interface and is report bp-544e2419-3744-408a-8d94-b46b10181212. ============================================================= Top 10 frames of crashing thread: 0 libxul.so nsHostResolver::ResolveHost mfbt/RefPtr.h:44 1 libxul.so nsDNSService::AsyncResolveInternal netwerk/dns/nsDNSService2.cpp:849 2 libxul.so nsDNSService::AsyncResolveNative netwerk/dns/nsDNSService2.cpp:913 3 libxul.so nsDNSPrefetch::Prefetch netwerk/base/nsDNSPrefetch.cpp:65 4 libxul.so mozilla::net::nsHttpChannel::MaybeStartDNSPrefetch netwerk/protocol/http/nsHttpChannel.cpp:6405 5 libxul.so mozilla::net::nsHttpChannel::BeginConnectActual netwerk/protocol/http/nsHttpChannel.cpp:6428 6 libxul.so mozilla::net::nsHttpChannel::BeginConnect netwerk/protocol/http/nsHttpChannel.cpp:6377 7 libxul.so mozilla::net::nsHttpChannel::OnProxyAvailable netwerk/protocol/http/nsHttpChannel.cpp:6671 8 libxul.so mozilla::net::nsAsyncResolveRequest::DoCallback netwerk/base/nsProtocolProxyService.cpp:396 9 libxul.so mozilla::net::nsAsyncResolveRequest::Run netwerk/base/nsProtocolProxyService.cpp:262 =============================================================
Group: core-security
Group: core-security → network-core-security
Keywords: csectype-uaf
Assignee: nobody → dd.mozilla
Status: NEW → ASSIGNED
Priority: -- → P1
Whiteboard: [necko-triaged]
There's an older crash with this signature, but the use-after-frees seem to have started with 64.x. Mostly on Android, but there's a couple windows UAFs too.

Dragana, do you think you'll have cycles to look at this during this cycle still?

Flags: needinfo?(dd.mozilla)

(In reply to Ryan VanderMeulen [:RyanVM] from comment #2)

Dragana, do you think you'll have cycles to look at this during this cycle still?

I was on PTO and back today.

I looked into this today a bit and I will continue looking... I may have a theory why this is happening.

Flags: needinfo?(dd.mozilla)

I don't see anything interesting in the reports that have logs on Android. The stack is kinda weird, though.

According to the reports, the crash is occuring in RefPtr::AddRef(), so we are likely creating a RefPtr with a garbage referent, but frame 1 points to the line[0] where nsDNSService::AsyncResolveInternal calls nsHostResolver::ResolveHost. We aren't creating a RefPtr here, but we would've for the new nsDNSAsyncRequest(...) just above for the mResolver member. Optimization side effect? Busted stack trace? Also, we're passing the value for mResolver from an existing RefPtr, so it doesn't make sense that it could suddenly become garbage.

[0] https://searchfox.org/mozilla-central/rev/330daedbeac2bba296d663668e0e0cf248bc6823/netwerk/dns/nsDNSService2.cpp#849

Is this still a P1 for this release cycle?

Flags: needinfo?(dd.mozilla)

(In reply to Emma Humphries, Bugmaster ☕️🎸🧞‍♀️✨ (she/her) [:emceeaich] (UTC-8) needinfo? me from comment #6)

Is this still a P1 for this release cycle?

I would like to fix it but currently I do not know what the next step should be.

I will keep it P1.

Flags: needinfo?(dd.mozilla)

Dragana, are you able to take another look? The crash volume went up quite a lot on 66.0.2 for Fennec.
Petru, cc-ing you into the bug in case you may be able to investigate.

Flags: needinfo?(petru.lingurar)

Sorry but all this seems native code for which I don't anything to contribute atm.
Feel free to ping me if there's anything to be done in the Android app.

Flags: needinfo?(petru.lingurar)

Actually - at this point, this isn't likely to be fixed for 66. But we could still take a patch for 68 or potentially, 67.

The volume of crashes on 67 beta is low and we don't currently have a patch in review orwhile we are one week away from RC week. Marking as fix-optional at this point for 67.

The cause seems to be the same as in bug 1549398. Looks like nsDNSService::mResolver is invalid, but I have no idea why...

Too late for a fix in 68 as we are a week away from release.

We do not know how to fix this at the moment.

OK. I'll mark this stalled for now. Dan just double checking that's ok with you.

Flags: needinfo?(dveditz)
Keywords: stalled

Christian, making you aware. This is likely a race in our DNS code we can't figure out.

Priority: P1 → P2
Flags: needinfo?(dveditz)

setting status for esr68 since these are mostly fennec crashes.

Removing employee no longer with company from CC list of private bugs.

Assignee: dd.mozilla → valentin.gosu

Comment on attachment 9206332 [details]
Bug 1513519 - Always hold lock when accessing mResolver r=#necko

Security Approval Request

  • How easily could an exploit be constructed based on the patch?: Racy code is rather obvious. Unclear how easy this would be to exploit.
  • 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?: all
  • If not all supported branches, which bug introduced the flaw?: None
  • Do you have backports for the affected branches?: Yes
  • If not, how different, hard to create, and risky will they be?: Easy to backport.
  • How likely is this patch to cause regressions; how much testing does it need?: Low risk of regressions - only locks mutex for sensitive operations
Attachment #9206332 - Flags: sec-approval?
Keywords: stalled

Comment on attachment 9206332 [details]
Bug 1513519 - Always hold lock when accessing mResolver r=#necko

sec-approval=dveditz

Attachment #9206332 - Flags: sec-approval? → sec-approval+
Group: network-core-security → core-security-release
Status: ASSIGNED → RESOLVED
Closed: 5 years ago
Resolution: --- → FIXED
Target Milestone: --- → 88 Branch

Please request beta/esr uplift when you get a chance.

Flags: needinfo?(valentin.gosu)

Comment on attachment 9206332 [details]
Bug 1513519 - Always hold lock when accessing mResolver r=#necko

ESR Uplift Approval Request

  • If this is not a sec:{high,crit} bug, please state case for ESR consideration: Sec-high
  • User impact if declined: nsDNSService::mResolver may be accessed from multiple threads without holding a lock leading to a use after free.
  • Fix Landed on Version: 88
  • Risk to taking this patch: Low
  • Why is the change risky/not risky? (and alternatives if risky): The patch makes no big logic changes. We just hold the lock when accessing the RefPtr in a few extra places in the code.
  • String or UUID changes made by this patch:

Beta/Release Uplift Approval Request

  • User impact if declined: nsDNSService::mResolver may be accessed from multiple threads without holding a lock leading to a use after free.
  • Is this code covered by automated tests?: Yes
  • Has the fix been verified in Nightly?: Yes
  • Needs manual test from QE?: No
  • If yes, steps to reproduce:
  • List of other uplifts needed: None
  • Risk to taking this patch: Low
  • Why is the change risky/not risky? (and alternatives if risky): The patch makes no big logic changes. We just hold the lock when accessing the RefPtr in a few extra places in the code.
  • String changes made/needed:
Flags: needinfo?(valentin.gosu)
Attachment #9206332 - Flags: approval-mozilla-esr78?
Attachment #9206332 - Flags: approval-mozilla-beta?
Flags: qe-verify-
Whiteboard: [necko-triaged] → [necko-triaged][post-critsmash-triage]

Comment on attachment 9206332 [details]
Bug 1513519 - Always hold lock when accessing mResolver r=#necko

approved for 87.0b8

Attachment #9206332 - Flags: approval-mozilla-beta? → approval-mozilla-beta+

Comment on attachment 9206332 [details]
Bug 1513519 - Always hold lock when accessing mResolver r=#necko

Approved for 78.9esr.

Attachment #9206332 - Flags: approval-mozilla-esr78? → approval-mozilla-esr78+

As part of a security bug pattern analysis, we are requesting your help with a high level analysis of this bug. It is our hope to develop static analysis (or potentially runtime/dynamic analysis) in the future to identify classes of bugs.

Please visit this google form to reply.

Flags: needinfo?(valentin.gosu)
Whiteboard: [necko-triaged][post-critsmash-triage] → [necko-triaged][post-critsmash-triage][sec-survey]
Whiteboard: [necko-triaged][post-critsmash-triage][sec-survey] → [necko-triaged][post-critsmash-triage][sec-survey][adv-main87+r]
Whiteboard: [necko-triaged][post-critsmash-triage][sec-survey][adv-main87+r] → [necko-triaged][post-critsmash-triage][sec-survey][adv-main87+r][adv-esr78.9+r]
Flags: needinfo?(valentin.gosu)
Group: core-security-release
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: