Loading of the notification API icon URI seems to be missing checks.
Categories
(Core :: DOM: Notifications, defect, P2)
Tracking
()
People
(Reporter: tiebuchen, Assigned: aaiunusov)
References
(Blocks 1 open bug, Regression)
Details
(4 keywords, Whiteboard: [client-bounty-form][adv-main146+][adv-esr115.31+][adv-esr140.6+])
Attachments
(2 files, 4 external files, 1 obsolete file)
A security vulnerability has been identified in Firefox's implementation of the Web Notifications API. The browser fails to properly validate and sanitize the icon parameter when creating notifications via new Notification(), allowing malicious actors to bypass multiple security restrictions that are properly enforced in Chromium-based browsers.
Firefox does not perform adequate security checks on the URL provided to the icon parameter in the Notification constructor. This oversight enables several security bypasses:
- Local Network Access Bypass
Issue: The notification icon feature can be exploited to make arbitrary requests to local network resources, bypassing Local Network Access restrictions.
Example:
new Notification('Test', {
icon: 'http://localhost/request_type?notification_icon'
});
Impact:
Attackers can probe and interact with services on the local network (localhost, private IP ranges)
Bypasses the browser's Local Network Access security model
Enables reconnaissance of local services and potential SSRF (Server-Side Request Forgery) attacks from the client side
- Local File System Access Bypass
Issue: The icon parameter accepts file:// protocol URLs, allowing direct access to local filesystem resources and bypassing same-origin policy isolation.
Example:
javascriptnew Notification('Test', {
icon: 'file:///c:/tmp/image.png'
});
Impact:
Bypasses browser restrictions on local file access
Violates the browser's security isolation model (sandbox/island mode)
Potential for information disclosure by accessing local files
Could be used to probe for the existence of specific files on the user's system
- Arbitrary URL Schema Handling
Issue: Firefox accepts arbitrary URL schemas in the icon parameter and prompts the user to open them, but critically fails to include the requesting origin URL in the prompt.
Example:
javascriptnew Notification('Test', {
icon: 'calculator:://test'
});
Impact:
Users may be prompted to open external applications without clear context of which website initiated the request
Lack of origin information in the prompt makes it difficult for users to make informed security decisions
Could be exploited for social engineering attacks
Potential for triggering malicious actions in external protocol handlers
Reproduce :
- open https://permission.site/ , click Notifications οΌ allow Notifications permission bubble prompt
- run the javascript code in the console
2.1. Local Network Access bypass
new Notification('Test1', {
icon: 'http://localhost/request_type?notification_icon'
});
2.2 Local file system access via file:// protocol
new Notification('Test2', {
icon: 'file:///c:/tmp/image.png'
});
2.3 Arbitrary URL schema handling without origin context
new Notification('Test3', {
icon: 'calculator:://test'
});
Updated•1 year ago
|
Updated•1 year ago
|
This will also bypass the CSP <meta http-equiv="Content-Security-Policy" content="img-src 'self'"> .
| Assignee | ||
Updated•1 year ago
|
| Assignee | ||
Updated•1 year ago
|
| Assignee | ||
Comment 2•1 year ago
|
||
| Assignee | ||
Comment 3•1 year ago
•
|
||
I managed to reproduce the bug with
new Notification('Test', { icon: 'calculator:://test' });
(Clipboard 1.jpg)
I think yes, icon parameter must be filtered before using
We must only allow the icons from the same domain
Updated•1 year ago
|
Updated•1 year ago
|
| Assignee | ||
Comment 5•1 year ago
|
||
I will submit a patch soon
| Assignee | ||
Comment 6•1 year ago
|
||
Updated•1 year ago
|
Updated•1 year ago
|
| Assignee | ||
Comment 7•1 year ago
|
||
was debugging a bit
So, https://searchfox.org/firefox-main/rev/75f89f7dee3f30c371af717da54ba8bbf046e5fd/toolkit/components/alerts/AlertNotification.cpp#425
here we pass correct Content principal, but it still allows to load all of this stuff (even with nsIContentPolicy::TYPE_IMAGE)
Comment 8•1 year ago
|
||
Nika was noting that was pass null as the document (presumably because we're in the parent process) so maybe that is causing us to skip a check somehow?
| Assignee | ||
Comment 9•1 year ago
|
||
okay, I am going to try <img> case with nullptr ass a document, to see what will happen
| Assignee | ||
Comment 10•1 year ago
•
|
||
nsresult imgLoader::LoadImage(
nsIURI* aURI, nsIURI* aInitialDocumentURI, nsIReferrerInfo* aReferrerInfo,
nsIPrincipal* aTriggeringPrincipal, uint64_t aRequestContextID,
nsILoadGroup* aLoadGroup, imgINotificationObserver* aObserver,
nsINode* aContext, Document* aLoadingDocument, nsLoadFlags aLoadFlags,
nsISupports* aCacheKey, nsContentPolicyType aContentPolicyType,
const nsAString& initiatorType, bool aUseUrgentStartForChannel,
bool aLinkPreload, uint64_t aEarlyHintPreloaderId,
FetchPriority aFetchPriority, imgRequestProxy** _retval) {
VerifyCacheSizes();
aLoadingDocument = nullptr; // <----
basically, makes no difference for <img> tag in terms of security
I'm continue debugging imgLoader..
| Assignee | ||
Comment 11•1 year ago
|
||
found exact cause:
for Notification icons imgLoader uses a system principal.
| Assignee | ||
Comment 12•1 year ago
|
||
from @smaug
So, worth to read https://bugzilla.mozilla.org/show_bug.cgi?id=1206961
| Assignee | ||
Comment 13•1 year ago
|
||
https://searchfox.org/firefox-main/rev/a7d872e9d28072c2dd6d688d1b6c0493fcf7e94c/image/imgLoader.cpp#932-933,936
so, at some point, the author who touched this code forgot Notification case and passed a system principal
| Assignee | ||
Comment 14•1 year ago
|
||
Comment on attachment 9523065 [details]
(secure)
Security Approval Request
- How easily could an exploit be constructed based on the patch?: patch is self explanatory for attackers (they will know it immediately)
- Do comments in the patch, the check-in comment, or tests included in the patch paint a bulls-eye on the security problem?: Yes
- Which branches (beta, release, and/or ESR) are affected by this flaw, and do the release status flags reflect this affected/unaffected state correctly?: all branches since the last 10 years
- If not all supported branches, which bug introduced the flaw?: Bug 1206961
- Do you have backports for the affected branches?: No
- If not, how different, hard to create, and risky will they be?: trivial
- How likely is this patch to cause regressions; how much testing does it need?: we do not know yet, and will need to push to try
- Is the patch ready to land after security approval is given?: Yes
- Is Android affected?: Yes
Updated•1 year ago
|
Comment 15•1 year ago
|
||
Set release status flags based on info from the regressing bug 1206961
Updated•1 year ago
|
Updated•1 year ago
|
| Assignee | ||
Comment 16•1 year ago
|
||
(waiting for a sec approval)
Updated•1 year ago
|
| Assignee | ||
Comment 17•1 year ago
|
||
Still waiting for security approval, in order to push-to-try before landing
Comment 18•1 year ago
|
||
Comment on attachment 9523065 [details]
(secure)
Approved to land and request uplift
Comment 19•1 year ago
|
||
Set release status flags based on info from the regressing bug 1206961
Comment 20•1 year ago
|
||
Comment 21•1 year ago
|
||
firefox-beta Uplift Approval Request
- User impact if declined: 10 years old security bug will persist
- Code covered by automated testing: yes
- Fix verified in Nightly: yes
- Needs manual QE test: no
- Steps to reproduce for manual QE testing:
- Risk associated with taking this patch: low
- Explanation of risk level: low risk due to the passed local tests (image load related)
- String changes made/needed: no
- Is Android affected?: yes
| Assignee | ||
Comment 22•1 year ago
|
||
Original Revision: https://phabricator.services.mozilla.com/D270427
Comment 23•1 year ago
|
||
firefox-esr115 Uplift Approval Request
- User impact if declined: 10 years old security bug will persist
- Code covered by automated testing: yes
- Fix verified in Nightly: yes
- Needs manual QE test: no
- Steps to reproduce for manual QE testing:
- Risk associated with taking this patch: low
- Explanation of risk level: low risk due to the passed local tests (image load related)
- String changes made/needed: no
- Is Android affected?: yes
| Assignee | ||
Comment 24•1 year ago
|
||
Original Revision: https://phabricator.services.mozilla.com/D270427
Comment 25•1 year ago
|
||
firefox-esr140 Uplift Approval Request
- User impact if declined: 10 years old security bug will persist
- Code covered by automated testing: yes
- Fix verified in Nightly: yes
- Needs manual QE test: no
- Steps to reproduce for manual QE testing:
- Risk associated with taking this patch: low
- Explanation of risk level: low risk due to the passed local tests (image load related)
- String changes made/needed: no
- Is Android affected?: yes
| Assignee | ||
Comment 26•1 year ago
|
||
Original Revision: https://phabricator.services.mozilla.com/D270427
| Assignee | ||
Comment 27•1 year ago
|
||
Original Revision: https://phabricator.services.mozilla.com/D270427
Updated•1 year ago
|
Comment 28•1 year ago
|
||
firefox-release Uplift Approval Request
- User impact if declined: 10 years old security bug will persist
- Code covered by automated testing: yes
- Fix verified in Nightly: yes
- Needs manual QE test: no
- Steps to reproduce for manual QE testing:
- Risk associated with taking this patch: low
- Explanation of risk level: low risk due to the passed local tests (image load related)
- String changes made/needed: no
- Is Android affected?: yes
Comment 29•1 year ago
|
||
Comment 30•1 year ago
|
||
The bounty team is debating whether this is really a sec-high or if it's more of a sec-moderate.
- bypassing CSP or iframe sandbox would be sec-moderate
- we haven't shipped LNA, but bypassing it would be sec-moderate
- loading files is normally forbidden, but what is the harm? the caller can't learn about the image/file. wrong for sure, but moderate?
- launching external protocols without asking the user: sec-vector? depends on the vulnerability of other apps. Do we at least still block the "known bad" protocols or does Chrome get a pass on that?
Updated•1 year ago
|
Updated•1 year ago
|
Updated•1 year ago
|
Comment 31•1 year ago
|
||
| uplift | ||
Updated•1 year ago
|
Updated•1 year ago
|
Updated•1 year ago
|
Updated•1 year ago
|
Updated•1 year ago
|
Comment 32•1 year ago
|
||
| uplift | ||
Comment 33•1 year ago
|
||
| uplift | ||
Comment 34•1 year ago
|
||
| uplift | ||
Comment 35•1 year ago
|
||
rolled back from esr115 for causing mochitest failures
Updated•1 year ago
|
| Assignee | ||
Comment 36•1 year ago
•
|
||
https://searchfox.org/firefox-main/source/toolkit/components/alerts/test/chrome/test_image.html#99
"Loading principal is HTTPS; image URL is HTTP."
I think it is a good idea not to allow loading this
But I'll see how to resolve this (maybe a test needs adjustment)
| Assignee | ||
Comment 37•1 year ago
•
|
||
security.mixed_content.upgrade_display_content
https://github.com/mozilla-firefox/firefox/blob/esr115/modules/libpref/init/StaticPrefList.yaml#L13701 - disabled in ESR115
https://github.com/mozilla-firefox/firefox/blob/esr140/modules/libpref/init/StaticPrefList.yaml#L16511 - enabled in ESR140 and later
I'll tweak a test and provide a patch for ESR115 soon
| Assignee | ||
Comment 38•1 year ago
•
|
||
It looks like esr115 was more strict about loading mixed content. And my patch is correct
This means the test is expected to fail. And it fails now.
I plan to change security.mixed_content.upgrade_display_content to false and test esr115 locally.
If this is the case, a minor test adjustment will be required (only checking the security.mixed_content.upgrade_display_content pref).
Updated•1 year ago
|
Comment 39•1 year ago
|
||
While I agree with the reporter that we were missing expected checks, I disagree with many of the hypothetical harms
Quoting from comment 0 with some formatting changes to make replies easier
Issue 1: icon: 'http://localhost/request_type?notification_icon'
Impact:
- Attackers can probe and interact with services on the local network (localhost, private IP ranges)
2, Bypasses the browser's Local Network Access security model- Enables reconnaissance of local services and potential SSRF (Server-Side Request Forgery) attacks from the client side
Yes, this allows the notifications API to do what web sites have been able to do since 1991, bypassing a protection mechanism we probably still won't ship by default for a couple of months. In Fx146 it will be part of "ETP Strict" for users who turn that on (bug 1991917).
It's definitely a bug, but not the worst thing.
Issue 2: icon: 'file:///c:/tmp/image.png'
Impact:
- Bypasses browser restrictions on local file access
- Violates the browser's security isolation model (sandbox/island mode)
- Potential for information disclosure by accessing local files
- Could be used to probe for the existence of specific files on the user's system
yes to #1. #2 appears to imagine reasons for the restriction that aren't true (it's not about isolation or sandboxing). #3 and #4 seem to be the same thing and are a main reason for the file: restriction in web pages, but how can you use notifications to conduct a probe or load a document to trigger the scripts it contains? the page sending the notification gets no feedback on whether the load succeeded or failed.
Issue 3: icon: 'calculator:://test'
Impact:
- Users may be prompted to open external applications without clear context of which website initiated the request
- Lack of origin information in the prompt makes it difficult for users to make informed security decisions
- Could be exploited for social engineering attacks
- Potential for triggering malicious actions in external protocol handlers
#1-3 are essentially the same: "this is confusing and someone could take advantage of it" (which is true: this is definitely unwanted behavior). For #2 specifically, the prompt shows up at exactly the same time as the notification, and the notification has the hostname of the responsible site. It's confusing, but not impossible to figure out. Hopefully when faced with a mystery prompt from a mystery location most users will hit "Cancel".
#4 is the primary reason for the prompt. That situation would be a security bug in that other app, but that does happen. Even with a proper prompt people can unwisely click "allow". In any case, there is no way for an external handler to be the source of an image so these simply should never have been allowed in an image context, prompt or no prompt.
from comment 1:
This will also bypass the CSP <meta http-equiv="Content-Security-Policy" content="img-src 'self'"> .
Since the image is not loaded into the document these notifications are outside the CSP threat model. Preventing exfiltration is explicitly specified as not a goal in the content security policy spec. Still, we should see if we can preserve the "policy container" for these requests because CSP is not the only thing that is likely to be missing
Sadly this patch is incomplete. It fixes issues 2 and 3, but because there's no document context (the requestingNode) not everything is fixed. There's still no LNA warning because we only know the origin of the notification, but don't know if it was loaded as a public or private site. And likewise we have no access to the document's content security policy so it still bypasses CSP as mentioned in comment 1.
It would be a confusing mess to reopen this bug so I will file a follow-up bug for the remaining issues
Comment 41•1 year ago
|
||
(It would be tricky to have a test of Notification API, because we don't expose the result as pointed out in comment #39, but we should be able to test AlertNotification itself in a mochitest.)
Comment 42•1 year ago
|
||
(But given we'll remove AlertNotification.loadImage, perhaps the test should be done in bug 2001265 than here...)
Updated•1 year ago
|
| Assignee | ||
Comment 43•1 year ago
|
||
(Regarding to the esr115 test. I will update a ESR115 patch soon.)
Updated•1 year ago
|
Updated•1 year ago
|
Comment 44•1 year ago
|
||
| uplift | ||
Updated•1 year ago
|
Updated•1 year ago
|
Updated•1 year ago
|
Updated•11 months ago
|
Updated•6 months ago
|
Description
•