Closed Bug 1671479 Opened 5 years ago Closed 5 years ago

Crash in [@ nsCOMPtr_base::assign_from_qi | nsBinaryOutputStream::WriteCompoundObject]

Categories

(Core :: Security: PSM, defect)

x86
Windows 7
defect

Tracking

()

RESOLVED FIXED
84 Branch
Tracking Status
firefox-esr78 83+ fixed
firefox81 - wontfix
firefox82 - wontfix
firefox83 + fixed
firefox84 + fixed

People

(Reporter: jesup, Assigned: valentin)

References

Details

(Keywords: crash, csectype-uaf, sec-high, Whiteboard: [sec-survey][adv-main83+r][adv-esr78.5+r])

Crash Data

Attachments

(1 file)

Fairly frequent e5e5 UAF crash:

Crash report: https://crash-stats.mozilla.org/report/index/fbd76a17-b2ba-44ff-91bb-dbc4f0201013

Reason: EXCEPTION_ACCESS_VIOLATION_READ

Top 10 frames of crashing thread:

0 xul.dll nsCOMPtr_base::assign_from_qi xpcom/base/nsCOMPtr.cpp:46
1 xul.dll nsBinaryOutputStream::WriteCompoundObject xpcom/io/nsBinaryStream.cpp:291
2 xul.dll mozilla::psm::TransportSecurityInfo::Write security/manager/ssl/TransportSecurityInfo.cpp:242
3 xul.dll nsBinaryOutputStream::WriteCompoundObject xpcom/io/nsBinaryStream.cpp:327
4 xul.dll NS_SerializeToString netwerk/base/nsSerializationHelper.cpp:23
5 xul.dll mozilla::net::HttpChannelParent::UpdateAndSerializeSecurityInfo netwerk/protocol/http/HttpChannelParent.cpp:1946
6 xul.dll mozilla::net::HttpChannelParent::OnStartRequest netwerk/protocol/http/HttpChannelParent.cpp:1241
7 xul.dll mozilla::net::ParentChannelListener::OnStartRequest netwerk/protocol/http/ParentChannelListener.cpp:90
8 xul.dll WindowlessBrowser::GetCanGoBack xpfe/appshell/nsAppShellService.cpp:357
9 xul.dll mozilla::extensions::ChannelWrapper::RequestListener::OnStartRequest toolkit/components/extensions/webrequest/ChannelWrapper.cpp:1074

No crashes past 82.0b9, so maybe fixed?

Group: core-security → network-core-security

It seems to me that the problem is we're holding the TransportSecurityInfo::mMutex in TransportSecurityInfo::Write but not in TransportSecurityInfo::SetSucceededCertChain

The crashes maybe went away if the timings of the callers changed, but I think the bug is still there.
Maybe we want to hold the mutex for TransportSecurityInfo::GetSucceededCertChain too?

Assignee: nobody → valentin.gosu
Component: Networking → Security: PSM
Flags: needinfo?(dkeeler)

Yes. Historically this class has not been rigorous in its thread-safety and we should address this.

Flags: needinfo?(dkeeler)
Blocks: 1672120

Nika/decoder - this is an example of a bug that (with the right GUARDED_BY/etc) might be caught during static analysis.

Comment on attachment 9181957 [details]
Bug 1671479 - Hold mutex when calling TransportSecurityInfo::Get/SetSucceededCertChain r=keeler

Security Approval Request

  • How easily could an exploit be constructed based on the patch?: Unclear if the race can be triggered by remote 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?: 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?: Grafts successfully on esr78
  • How likely is this patch to cause regressions; how much testing does it need?: Since it only involves holding the mutex while accessing mSucceededCertChain this is unlikely to cause regressions unless there is timing sensitive code/race that might be affected by the delay holding the mutex.
Attachment #9181957 - Flags: sec-approval?

Valentin, is this code covered by our tests and if so, which tests might apply? I was wondering why we wouldn't see this in TSan if there is a data race present. Maybe also an existing suppression is hiding it or we have it on file somewhere but didn't recognize it as a problem? Also, I assume this is not Windows-only?

Flags: needinfo?(valentin.gosu)

Recent reports say it's Windows and OSX only.
From what I can tell from the stack traces I've looked at, they all seem to have:
mozilla::extensions::ChannelWrapper::RequestListener::OnStartRequest(nsIRequest*)
So presumably this only happens with a specific extension installed?

Flags: needinfo?(valentin.gosu)

Comment on attachment 9181957 [details]
Bug 1671479 - Hold mutex when calling TransportSecurityInfo::Get/SetSucceededCertChain r=keeler

Approved to land and uplift

Attachment #9181957 - Flags: sec-approval?
Attachment #9181957 - Flags: sec-approval+
Attachment #9181957 - Flags: approval-mozilla-esr78+
Attachment #9181957 - Flags: approval-mozilla-beta+
Group: network-core-security → core-security-release
Status: NEW → RESOLVED
Closed: 5 years ago
Resolution: --- → FIXED
Target Milestone: --- → 84 Branch

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: [sec-survey]

(In reply to Release mgmt bot [:sylvestre / :calixte / :marco for bugbug] from comment #13)

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.

Done 👍

Flags: needinfo?(valentin.gosu)
Whiteboard: [sec-survey] → [sec-survey][adv-main83+r]
Whiteboard: [sec-survey][adv-main83+r] → [sec-survey][adv-main83+r][adv-esr78.5+r]

I see some of the signatures have moved over to crashing on mFailedCertChain. I should have fixed that one too. 🤦‍‍♂️
Presumably we can fix those in bug 1672120.

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: