Latent use after free in QueuedDataMessage()
The QueuedDataMessage class has defaulted move constructor and move-assignment operator that would cause use-after-free if used, because the moved-from object still frees the same buffer. The text states these are currently not used, so no exploit is demonstrated.
Originally disclosed on Mozilla
- Fixed in 49 days
- Paid in 55 days
- Disclosed after 49 days
`QueuedDataMessage()` (`netwerk/sctp/datachannel/DataChannel.h`) would cause uses after free if its defaulted move constructor or its defaulted move-assignment operator were used. They currently are not used, as FF still builds successfully when I change them to deleted.
From `FIREFOX_124_0_2_RELEASE`:
'''
103: class QueuedDataMessage {
104: public:
105: QueuedDataMessage(uint16_t stream, uint32_t ppid, int flags, const void* data,
106: uint32_t length)
107: : mStream(stream), mPpid(ppid), mFlags(flags), mLength(length) {
108: mData = static_cast<uint8_t*>(moz_xmalloc((size_t)length)); // infallible
109: memcpy(mData, data, (size_t)length);
110: }
111: QueuedDataMessage(QueuedDataMessage&& other) = default;
112: QueuedDataMessage& operator=(QueuedDataMessage&& other) = default;
113: ~QueuedDataMessage() { free(mData); }
...
119: uint8_t* mData;
120: };
'''
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely the defaulted move operations shallow-copy the raw pointer mData without transferring ownership, so the moved-from object still frees the buffer in its destructor.
Impact
No impact is demonstrated because the dangerous move operations are not currently used; the text only notes the latent risk if they were used.
What the attacker needed
None
The fix
The move constructor and move-assignment operator should be deleted or implemented to transfer ownership safely, as the text suggests deleting them works.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
A use-after-free is a bug where a program keeps using memory after it has been freed, which can lead to crashes or, in some cases, attackers running their own code. Here, the class that holds a message buffer has automatic move operations that copy the pointer but leave the original object still responsible for freeing it, so if those operations were ever used, the same memory could be freed twice or used after being freed. The report notes the dangerous operations are not currently used in Firefox.
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.