Closed Bug 1648825 Opened 4 years ago Closed 3 years ago

Fetch Metadata Headers contain invalid value for Sec-Fetch-Site for history manipulation

Categories

(Core :: DOM: Security, defect, P3)

79 Branch
defect

Tracking

()

RESOLVED FIXED
90 Branch
Tracking Status
firefox90 --- fixed

People

(Reporter: terjanq, Assigned: n.goeggi)

References

Details

(Whiteboard: [domsecurity-backlog1])

Attachments

(2 files, 4 obsolete files)

User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.116 Safari/537.36

Steps to reproduce:

PoC: https://terjanq.appspot.com/sec-fetch/reports/location-hash-bypass.html

  1. On abc.com origin load xyz.com page in iframe.
  2. Set location of the loaded iframe to xyz.com#123
  3. Set location of the iframe to same-origin, i.e. abc.com
  4. Call history.back() on the iframe

Please note that the xyz.com should set either Cache-Control: no-store or must-revalidate, because Firefox will likely load the page from cache otherwise, so there will be no additional request sent to the server.

Actual results:

After 4th step, the browser will send header Sec-Fetch-Site: none.

Expected results:

The browser should not send Sec-Fetch-Site: none, it is not yet clear what value it should be but Chrome sets cross-site as for an example.

It's possible that the behaviour has the same root cause as https://bugzilla.mozilla.org/show_bug.cgi?id=1647128

Blocks: 1508292
Severity: -- → S4
Priority: -- → P3
Whiteboard: [domsecurity-backlog1]
Assignee: nobody → ckerschb
Blocks: 1695911
Assignee: ckerschb → nobody
Assignee: nobody → ngogge
Status: UNCONFIRMED → ASSIGNED
Ever confirmed: true

Some thoughts about fixing this bug:

  • First, (though not directly related to this bug) we should fix Bug 1698767 to avoid any unwanted side effects.
  • Second, relying on the referrerInfo to be present to determine IsUserTriggeredForSecFetchSite is a semi optimal solution and might cause other problems, besides the mentioned history manipulation in this bug. For Sec-Fetch-User we rely on loadInfo->GetHasValidUserGestureActivation(), maybe that's an option to factor in here too?

Depends on D108035

Hey Edgar,

While investigating this Bug i came across some code that you wrote and i have a couple of questions.

When the reload button is clicked by the user, the LoadURI method is called from here and by then i would have expected that mBrowsingContext->GetCurrentWindowContext()->HasValidTransientUserGestureActivation() would return true, since the load is triggered by the user through the reload button but it returns false.
What do you think, should it return true? If so, I feel like there is a missing call somewhere to WindowContext::NotifyUserGestureActivation() in the context of a user triggered reload.

Flags: needinfo?(echen)

(In reply to Niklas from comment #4)

When the reload button is clicked by the user, the LoadURI method is called from here and by then i would have expected that mBrowsingContext->GetCurrentWindowContext()->HasValidTransientUserGestureActivation() would return true, since the load is triggered by the user through the reload button but it returns false.

The click happens on the reload button which is in the browser window, so it only activates the WindowContext of the browsing window.
If the mBrowsingContext is the web content one, it would stay false as the user interacts with the browser, not the web content.

Flags: needinfo?(echen)
Attachment #9209500 - Attachment description: Bug 1648825 - Ensure that Sec-Fetch-Site is only 'none' if the load was user triggered. r=ckerschb → Bug 1648825 - Add user activation flag to ChildSHistory::reload. r=ckerschb

Depends on D108657

Depends on D109641

AFAICT there was no way for the content process to know if a reload or history manipulation was triggered by the user or not.
In this patch i added a aUserActivation boolean to the ipc methods so the parent can tell the content process if it has a user activation. (this and this patch are analogous to that for back and forward).

Would this be a viable approach in your opinion? or would you have a different idea?

Flags: needinfo?(echen)
Attachment #9211300 - Attachment description: Bug 1648825 - Add user activation flag to goBack(). r=ckerschb → WIP: Bug 1648825 - Add user activation flag to goBack(). r=ckerschb
Attachment #9211301 - Attachment description: Bug 1648825 - Add user activation flag to goForward(). r=ckerschb → WIP: Bug 1648825 - Add user activation flag to goForward(). r=ckerschb
Attachment #9211302 - Attachment description: Bug 1648825 - Ensure that Sec-Fetch-Site is only 'none' if the load was user triggered. r=ckerschb → WIP: Bug 1648825 - Ensure that Sec-Fetch-Site is only 'none' if the load was user triggered. r=ckerschb

Has left some comments in phabricator.

Flags: needinfo?(echen)
Attachment #9209500 - Attachment description: Bug 1648825 - Add user activation flag to ChildSHistory::reload. r=ckerschb → WIP: Bug 1648825 - Add user activation flag to ChildSHistory::reload. r=ckerschb
Attachment #9209500 - Attachment description: WIP: Bug 1648825 - Add user activation flag to ChildSHistory::reload. r=ckerschb → Bug 1648825 - Add user activation flag to ChildSHistory::reload. r=ckerschb
Attachment #9211300 - Attachment description: WIP: Bug 1648825 - Add user activation flag to goBack(). r=ckerschb → Bug 1648825 - Add user activation flag to goBack(). r=ckerschb
Attachment #9211301 - Attachment description: WIP: Bug 1648825 - Add user activation flag to goForward(). r=ckerschb → Bug 1648825 - Add user activation flag to goForward(). r=ckerschb
Attachment #9211302 - Attachment description: WIP: Bug 1648825 - Ensure that Sec-Fetch-Site is only 'none' if the load was user triggered. r=ckerschb → Bug 1648825 - Ensure that Sec-Fetch-Site is only 'none' if the load was user triggered. r=ckerschb
Attachment #9211301 - Attachment is obsolete: true
Attachment #9211300 - Attachment is obsolete: true
Attachment #9209500 - Attachment is obsolete: true

Comment on attachment 9212500 [details]
Bug 1648825 - Add user activation flag to reload, goBack and goForward r=ckerschb

Revision D110245 was moved to bug 1708150. Setting attachment 9212500 [details] to obsolete.

Attachment #9212500 - Attachment is obsolete: true
Depends on: 1708150
Attachment #9211302 - Attachment description: Bug 1648825 - Ensure that Sec-Fetch-Site is only 'none' if the load was user triggered. r=ckerschb → WIP: Bug 1648825 - Ensure that Sec-Fetch-Site is only 'none' if the load was user triggered. r=ckerschb
Attachment #9219267 - Attachment description: WIP: Bug 1648825 - Add nsISHEntry::hasUserActivation r=ckerschb → Bug 1648825 - Add nsISHEntry::hasUserActivation r=ckerschb
Attachment #9211302 - Attachment description: WIP: Bug 1648825 - Ensure that Sec-Fetch-Site is only 'none' if the load was user triggered. r=ckerschb → Bug 1648825 - Ensure that Sec-Fetch-Site is only 'none' if the load was user triggered. r=ckerschb
Pushed by mozilla@christophkerschbaumer.com:
https://hg.mozilla.org/integration/autoland/rev/5aece2a17f5d
Add nsISHEntry::hasUserActivation r=ckerschb,smaug
https://hg.mozilla.org/integration/autoland/rev/d90566e41269
Ensure that Sec-Fetch-Site is only 'none' if the load was user triggered. r=ckerschb,marionette-reviewers,whimboo
Regressions: 1712095
Pushed by mozilla@christophkerschbaumer.com:
https://hg.mozilla.org/integration/autoland/rev/a25184e549ad
Add nsISHEntry::hasUserActivation r=ckerschb,smaug
https://hg.mozilla.org/integration/autoland/rev/a84a2e535ffd
Ensure that Sec-Fetch-Site is only 'none' if the load was user triggered. r=ckerschb,marionette-reviewers,whimboo
Status: ASSIGNED → RESOLVED
Closed: 3 years ago
Resolution: --- → FIXED
Target Milestone: --- → 90 Branch
Flags: needinfo?(ngogge)
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: