Skip to content
Memory corruption Disclosed report Advanced CVE-2023-6205

heap-use-after-free messagechannel/MessagePort.cpp:574 in mozilla::dom::MessagePort::Entangled

m.cooolie Follow

Originally disclosed on Mozilla

  • Fixed in 38 days
  • Paid in 48 days
  • Disclosed after 38 days
Text
Created attachment 9354066
poc.zip

#Summary
heap-use-after-free messagechannel/MessagePort.cpp:574 in mozilla::dom::MessagePort::Entangled

#Reproduce
OS:Win10 X64
119.0a1 (2023-09-20) (64-bit)

step:
1. python -m http.server 1337
2. python -m ffpuppet firefox.exe -p prefs.js -d -u http://localhost:1337/poc_heavy_but_stable.html

NOTE!
poc_heavy_but_stable.html (Samples before minimization can reproduce the issue stably)
poc_mini_not_stable.html (Minimizing the sample may be helpful for analysis, but it cannot be stably reproduced)

#Type of crash
Tab process

#Analysis
MessagePortChild uses mPort to hold the original pointer of MessagePort. 
The comment explains that it is because "this child is owned by this MessagePort", but this comment seems incorrect.
Searching the code found that MessagePortChild was created at [2] and assigned to MessagePort at [3].

'''
class MessagePortChild final : public PMessagePortChild {
  friend class PMessagePortChild;

 public:
  NS_INLINE_DECL_REFCOUNTING(MessagePortChild)

  MessagePortChild();

  void SetPort(MessagePort* aPort) { mPort = aPort; }
---CUT---

  // This is a raw pointer because this child is owned by this MessagePort.
  MessagePort* mPort;
};
'''
[2]
https://searchfox.org/mozilla-central/source/ipc/glue/BackgroundChildImpl.cpp#441
RefPtr<dom::MessagePortChild> agent = new dom::MessagePortChild(); // found in mozilla::ipc::BackgroundChildImpl::AllocPMessagePortChild

[3]
https://searchfox.org/mozilla-central/source/dom/messagechannel/MessagePort.cpp#794
mActor = static_cast<MessagePortChild*>(actor); // found in mozilla::dom::MessagePort::ConnectToPBackground

#FIX Suggestion
If the above analysis is correct,RefPtr  can be used to resolve the issue.

The original report as published on Mozilla's Bugzilla, by m.cooolie. Images and videos are our own copies; raw HTML is shown as text. View it on Mozilla's Bugzilla.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

What is known

A high-severity memory corruption bug in DOM: postMessage. Mozilla made it public on 27 October 2023 as CVE-2023-6205.

About Memory corruption

Native code reads or writes memory it should not: overflows, use-after-free, type confusion. The core of browser, kernel and parser bugs.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

What is Memory corruption?

Native code reads or writes memory it should not: overflows, use-after-free, type confusion. The core of browser, kernel and parser bugs.

More by m.cooolie

View all

10 more disclosed reports, best first.

More from Mozilla

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Memory corruption

The lesson behind this report.

Native code reads or writes memory it should not: overflows, use-after-free, type confusion. The core of browser, kernel and parser bugs.