Closed Bug 2083440 Opened 1 month ago Closed 1 month ago

NavigateEvent.sourceElement exposed to cross-origin frames

Categories

(Core :: DOM: Navigation, defect)

Firefox 160
defect

Tracking

()

RESOLVED FIXED
160 Branch
Tracking Status
firefox160 --- fixed

People

(Reporter: shannon.ml.booth, Assigned: farre)

References

Details

Attachments

(1 external file)

User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.5 Safari/605.1.15

Steps to reproduce

See WPT: https://github.com/web-platform-tests/wpt/blob/master/navigation-api/navigate-event/sourceElement-cross-origin.sub.html

Spec PR: https://github.com/whatwg/html/pull/13090

Actual results

Firefox exposes an inaccessible element.

Expected results

sourceElement should be null when the initiator is not same origin-domain, matching Chromium and WebKit

The Bugbug bot thinks this bug should belong to the 'Core::CSS Parsing and Computation' component, but is not confident enough to move the bug to that component.

Component: Untriaged → General

This belongs in Core :: DOM: Navigation. The same-document fragment path in nsDocShell.cpp passes aLoadState->GetSourceElement() to the navigate event with no origin check, and Step 16 of Navigation::InnerFireNavigateEvent in Navigation.cpp copies it into init.mSourceElement unconditionally, so a same-process cross-origin iframe receives the parent's <a>. The element arrives behind an opaque wrapper, which is why the WPT times out on .tagName instead of failing.

Fix: Implement whatwg/html#13090 at that step by setting aSourceElement to null unless GetAssociatedDocument()->NodePrincipal()->EqualsConsideringDomain(aSourceElement->NodePrincipal()), then remove the TIMEOUT expectation in sourceElement-cross-origin.sub.html.ini, with the existing same-origin navigate-anchor-* and navigate-form-* WPTs guarding against over-nulling.

Suggested severity: S3. This is an interop and spec-compliance defect, and pages can only observe that a cross-origin initiator element exists, not read it, because the opaque wrapper blocks property access and cross-process loads already drop the element.


If you'd like to provide feedback on this comment, please use the 👍 or 👎 reaction.
If you want to categorize your feedback you can add one of the following tags: ai-triage-{wrong-file, wrong-cause, hallucination, out-of-scope, not-a-bug, wrong-fix, shallow-fix, wrong-severity}.

Needinfo hackbot@mozilla.tld to have a patch generated for this bug, include any questions or directions as needed in your comment.

Component: General → DOM: Navigation
Product: Firefox → Core
Flags: needinfo?(afarre)
Assignee: nobody → afarre
Status: UNCONFIRMED → ASSIGNED
Ever confirmed: true
Flags: needinfo?(afarre)
Pushed by afarre@mozilla.com: https://github.com/mozilla-firefox/firefox/commit/119551e36936 https://hg.mozilla.org/integration/autoland/rev/73302782c5b7 Don't expose NavigateEvent.sourceElement to cross-origin frames. r=dom-core-reviewers,jjaschke
Status: ASSIGNED → RESOLVED
Closed: 1 month ago
Resolution: --- → FIXED
Target Milestone: --- → 160 Branch
QA Whiteboard: [qa-triage-done-c161/b160]
See Also: → 2094566
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: