Skip to content
Access control Disclosed report Advanced

Indexing error in MediaStreamGraphImpl::UnregisterCaptureStreamForWindow might cause cross-site access

An array-removal loop in the media stream graph code skips the element shifted into the removed slot, so a capture stream entry that should be deleted can be left behind. The reporter suspects this could let a site in a window that previously hosted another site use a stream object from the previous site, but is unsure.

q1 Follow

Originally disclosed on Mozilla

  • Fixed in 19 days
  • Paid in 33 days
  • Disclosed after 19 days
Text
MediaStreamGraphImpl::UnregisterCaptureStreamForWindow (dom\media\MediaStreamGraph.cpp) incorrectly indexes an array, potentially causing it to leave in place an element that it should have deleted.

3820: void
3821: MediaStreamGraphImpl::UnregisterCaptureStreamForWindow(uint64_t aWindowId)
3822: {
3823:   MOZ_ASSERT(NS_IsMainThread());
3824:   for (uint32_t i = 0; i < mWindowCaptureStreams.Length(); i++) {
3825:     if (mWindowCaptureStreams[i].mWindowId == aWindowId) {

The bug is that the following line removes element |i| (e.g., element 3), which causes element |i+1| (e.g., element 4) (if it exists) to be shifted down to element |i| (e.g., element 3). However, when control returns to line 3824, above, |i| is incremented (e.g., to 4), so the next time line 3825 examines an element of mWindowCaptureStreams, it doesn't test the first element that was shifted down (e.g., 3), and so line 3826 doesn't remove it if it should be removed.

3826:       mWindowCaptureStreams.RemoveElementAt(i);
3827:     }
3828:   }
3829: }

I have marked this as a security bug because I'm unsure whether it might allow, e.g., a site opened in a window that previously hosted a different site, to then use a stream object from the previous site.

The original report as published on Mozilla's Bugzilla, by q1. 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.

How it worked

Root cause

Likely removing an element from an array while iterating forwards with an incrementing index, so the element shifted into the removed position is skipped.

Impact

A capture stream entry that should be removed may persist, which could potentially allow a site in a window that previously hosted a different site to use a stream object from the previous site; the reporter is unsure whether this is actually exploitable.

What the attacker needed

Window previously hosted another site; capture stream registered for that window

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 loop walks through a list and deletes matching entries. Deleting an entry shifts the following entries down by one, but the loop then moves on, so the entry that just moved into the deleted slot is never checked. The reporter worries this could leave a leftover stream object tied to a window, possibly letting a later site in that window reach the earlier site's stream, though this is not confirmed.

What is Access control?

A user can do something their role should not allow: reach an admin function, act on a feature they have not paid for, or skip a permission check. IDOR is the special case where the object belongs to someone else.

More by q1

View all

71 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.

Broken access control

The lesson behind this report.

A user can do something their role should not allow: reach an admin function, act on a feature they have not paid for, or skip a permission check. IDOR is the special case where the object belongs to someone else.