Closed Bug 1893332 Opened 2 years ago Closed 2 years ago

Latent use after free in QueuedDataMessage()

Categories

(Core :: WebRTC: Networking, defect)

defect

Tracking

()

RESOLVED FIXED
129 Branch
Tracking Status
firefox-esr115 --- unaffected
firefox125 --- wontfix
firefox126 --- wontfix
firefox127 --- wontfix
firefox128 --- wontfix
firefox129 + fixed

People

(Reporter: mozillabugs, Assigned: pehrsons)

References

(Regression)

Details

(4 keywords, Whiteboard: [adv-main129-])

Attachments

(7 files, 1 obsolete file)

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: };
Flags: sec-bounty?
Group: core-security → media-core-security
Component: Networking → WebRTC: Networking

I'm not sure what the right rating for this is. Surely we should fix it, but presumably if we did start calling it, the UAF would get detected by ASan, so it would have to be some use we didn't test which doesn't seem too likely.

No longer blocks: webrtc-triage
Severity: -- → S3
Flags: needinfo?(apehrson)
Assignee: nobody → apehrson
Flags: needinfo?(apehrson)
Keywords: regression
Regressed by: 1862740

Set release status flags based on info from the regressing bug 1862740

Set release status flags based on info from the regressing bug 1862740

Status: NEW → ASSIGNED

See C.20 at
https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#c20-if-you-can-avoid-defining-default-operations-do

This is refering to C.20's:

Enforcement

(Not enforceable) While not enforceable, a good static analyzer can detect
patterns that indicate a possible improvement to meet this rule. For example,
a class with a (pointer, size) pair of members and a destructor that deletes
the pointer could probably be converted to a vector.

See C.20 at
https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#c20-if-you-can-avoid-defining-default-operations-do

This is refering to C.20's:

Enforcement

(Not enforceable) While not enforceable, a good static analyzer can detect
patterns that indicate a possible improvement to meet this rule. For example,
a class with a (pointer, size) pair of members and a destructor that deletes
the pointer could probably be converted to a vector.

Attachment #9406595 - Attachment is obsolete: true
Pushed by pehrsons@gmail.com: https://hg.mozilla.org/integration/autoland/rev/e7d0e9781f0b In DataChannel.h's OutgoingMsg per C.20 use rule of zero. r=bwc https://hg.mozilla.org/integration/autoland/rev/03198220d900 In DataChannel.h per C.22 don't use default move ctor/assignment with custom dtor. r=bwc https://hg.mozilla.org/integration/autoland/rev/58797638fb29 In DataChannel.h per C.21 "the rule of five", also define copy constructors and assignment operators. r=bwc https://hg.mozilla.org/integration/autoland/rev/97f62907f179 In DataChannel, update includes. r=bwc https://hg.mozilla.org/integration/autoland/rev/aba58f0f46eb In OutgoingMsg and BufferedOutgoingMsg, per C.20, remove the need for a custom dtor. r=bwc https://hg.mozilla.org/integration/autoland/rev/b027447fbfdf In QueuedDataMessage, per C.20, remove the need for a custom dtor. r=bwc https://hg.mozilla.org/integration/autoland/rev/2e0a2fc356c1 Tighten DataChannel thread-safety annotations. r=bwc

The patch landed in nightly and beta is affected.
:pehrsons, is this bug important enough to require an uplift?

  • If yes, please nominate the patch for beta approval.
  • If no, please set status-firefox128 to wontfix.

For more information, please visit BugBot documentation.

Flags: needinfo?(apehrson)
Flags: needinfo?(apehrson)
Flags: sec-bounty? → sec-bounty+
QA Whiteboard: [post-critsmash-triage]
Flags: qe-verify-
Whiteboard: [adv-main129+]
Whiteboard: [adv-main129+] → [adv-main129-]
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: