Closed
Bug 1476094
Opened 7 years ago
Closed 7 years ago
webextensions: fetch API leaks cookies into user env
Categories
(WebExtensions :: Request Handling, defect)
Tracking
(Not tracked)
RESOLVED
INVALID
People
(Reporter: mklehr, Unassigned)
Details
User Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Ubuntu Chromium/66.0.3359.181 Chrome/66.0.3359.181 Safari/537.36
Steps to reproduce:
1. Fetch a web resource from inside a webextension using fetch API and Basic Auth.
2. The server sends cookies that represent the new session for the site.
Actual results:
3. In a normal browser tab, the user is now logged in to the site, without having entered their credentials.
Expected results:
The cookie jar of a webextension shouldn't be shared with the normal browsing session.
I'm not entirely certain if this is a Networking: Cookies related issue or a WebExtensions-related one. Please correct the component if this isn't the case. Thanks.
Component: Untriaged → Networking: Cookies
Product: Firefox → Core
Hi Marcel, which WebExtension did you use in particular for this test?
Flags: needinfo?(mklehr)
| Reporter | ||
Comment 3•7 years ago
|
||
It turns out I can't reproduce this. My fault. I'm sorry for the disturbance.
Status: UNCONFIRMED → RESOLVED
Closed: 7 years ago
Flags: needinfo?(mklehr)
Resolution: --- → WORKSFORME
| Reporter | ||
Comment 4•7 years ago
|
||
Actually, I can reproduce it now:
I'm the developer of floccus (available on AMO). It syncs bookmarks with nextcloud. When I clear all browser data and cookies and go to my nextcloud afterwards, I don't see any cookies being sent. However, if I clear the browser data, sync my bookmarks with the same nextcloud, and only after that access my nextcloud, I see the session data being transmitted in the browser console (network tab).
| Reporter | ||
Updated•7 years ago
|
Status: RESOLVED → UNCONFIRMED
Resolution: WORKSFORME → ---
I believe we put cookies into jars based on originattributes. Sounds to me like, perhaps, the fetch api, when used within a webextension, isn't setting the originattributes correctly to shove these cookies in the proper jar, but that's just my best first guess. Putting in core/dom networking to get (what I hope are) the appropriate eyes on this.
Component: Networking: Cookies → DOM: Networking
Comment 6•7 years ago
|
||
(In reply to Marcel Klehr from comment #0)
> User Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like
> Gecko) Ubuntu Chromium/66.0.3359.181 Chrome/66.0.3359.181 Safari/537.36
>
> Steps to reproduce:
>
> 1. Fetch a web resource from inside a webextension using fetch API and Basic
> Auth.
> 2. The server sends cookies that represent the new session for the site.
Can you provide a code example of how you are using fetch?
Are you using it in a content script, background script, etc?
| Reporter | ||
Comment 8•7 years ago
|
||
Sure, the code of my extension is open source. Here is a link to the fetch call: https://github.com/marcelklehr/floccus/blob/master/src/lib/adapters/Nextcloud.js#L258
I haven't tested the problem after adding the credentials: 'omit' (which was added after Chrome changed the default from 'omit' to 'same-origin')
The code runs in a background script
Flags: needinfo?(mklehr)
Comment 9•7 years ago
|
||
Moving to webextensions for now to determine:
1. if this is really a bug
2. the source of the bug (if we are not setting the proper originAttributes)
3. how it should be fixed
A test for the desired behaviour would be very helpful.
Component: DOM: Networking → Request Handling
Product: Core → WebExtensions
Comment 10•7 years ago
|
||
This is expected. It works the other way too: if a user logs into a site in a normal tab, requests from an extension contain those session cookies.
It would probably be nice to allow extensions to make requests associated with a particular container, but that's a separate bug.
Status: UNCONFIRMED → RESOLVED
Closed: 7 years ago → 7 years ago
Resolution: --- → INVALID
| Reporter | ||
Comment 11•7 years ago
|
||
> if a user logs into a site in a normal tab, requests from an extension contain those session cookies.
Oh. From a security perspective I'm thinking it would probably make sense to have a more fine-granular permission system that allows making requests without automatically sending all available cookies along, and thus having access to all accounts of that user. This can cause a lot of side effects aside from being a very broad permission. Thanks for clearing this up, though. :)
You need to log in
before you can comment on or make changes to this bug.
Description
•