inconsistent parsing of relative URLs starting with "///something" with a path-traversal "/../" part
Categories
(Core :: Networking, defect, P2)
Tracking
()
People
(Reporter: rachmat.abdul.ro, Assigned: valentin)
References
Details
(Keywords: reporter-external, sec-moderate, Whiteboard: [adv-main120+][adv-esr115.5+][reporter-external] [client-bounty-form] [verif?][necko-triaged][necko-priority-queue])
Attachments
(4 files)
Mozilla Firefox will ask for confirmation when accessing a url that does not require authentication using the basic auth scheme. By crafting a payload on the href property in the html link attackers can bypass the process of confirmation.
Step to reproduce :
- Install web server
- Create html file and save it to your web server path (example of html file is attached)
- Open html file
Live demo : http://206.189.194.11/p0c.html
Poc video : https://drive.google.com/file/d/1NXP2MEikvXx0YLybfewHhe16FAXRmbal/view?usp=sharing
Comment 1•1 year ago
|
||
The confirmations of our anti-phishing feature are a red-herring. The problem is we are mis-parsing relative URLs. Or maybe Chrome and Safari are? But at least they agree. In a a two-slash relative URL, we know the first part is a hostname, so we don't let any processing of path traversal segments ("/../") affect what we know is the host name. href="//mozilla.org/../evil.com"
goes to https://mozilla.org/evil.com
When an href starts with three slashes we maybe treat it as an empty host, and then let the path collapsing erase the first term. But then when we actually put it all together with the scheme we do treat the term after 3 slashes as the host. href="///mozilla.org/../evil.com"
goes to https://evil.com
Testcase:
var base = "https://example.com";
console.log("3-slash relative is the same as 2-slash: ",
(new URL("///mozilla.org/evil.com",base)).href == (new URL("//mozilla.org/evil.com",base)).href );
console.log("3-slash relative with path traversal is the same as 2-slash: ",
(new URL("///mozilla.org/../evil.com",base)).href == (new URL("//mozilla.org/../evil.com",base)).href );
In Chrome and Safari both are true. In Firefox the first is true and the second is false.
This isn't exactly a security bug in Firefox itself, but this difference with other browsers could contribute to Firefox-user-only website vulnerabilities. I think this should fit nicely with the 2023 URL interop effort. Would it be easier to incorporate into the testsuite if this were not a hidden bug?
Updated•1 year ago
|
Assignee | ||
Comment 2•1 year ago
|
||
Right, this is something where Firefox diverges from the spec
https://jsdom.github.io/whatwg-url/#url=Ly8vbW96aWxsYS5vcmcvLi4vZXZpbC5jb20=&base=aHR0cDovL2V4YW1wbGUuY29t
We should definitely fix it.
Assignee | ||
Updated•1 year ago
|
Assignee | ||
Comment 3•1 year ago
|
||
Assignee | ||
Comment 4•1 year ago
|
||
Depends on D190784
Reporter | ||
Comment 5•1 year ago
|
||
(In reply to Daniel Veditz [:dveditz] from comment #1)
The confirmations of our anti-phishing feature are a red-herring. The problem is we are mis-parsing relative URLs. Or maybe Chrome and Safari are? But at least they agree. In a a two-slash relative URL, we know the first part is a hostname, so we don't let any processing of path traversal segments ("/../") affect what we know is the host name.
href="//mozilla.org/../evil.com"
goes to https://mozilla.org/evil.comWhen an href starts with three slashes we maybe treat it as an empty host, and then let the path collapsing erase the first term. But then when we actually put it all together with the scheme we do treat the term after 3 slashes as the host.
href="///mozilla.org/../evil.com"
goes to https://evil.comTestcase:
var base = "https://example.com"; console.log("3-slash relative is the same as 2-slash: ", (new URL("///mozilla.org/evil.com",base)).href == (new URL("//mozilla.org/evil.com",base)).href ); console.log("3-slash relative with path traversal is the same as 2-slash: ", (new URL("///mozilla.org/../evil.com",base)).href == (new URL("//mozilla.org/../evil.com",base)).href );
In Chrome and Safari both are true. In Firefox the first is true and the second is false.
This isn't exactly a security bug in Firefox itself, but this difference with other browsers could contribute to Firefox-user-only website vulnerabilities. I think this should fit nicely with the 2023 URL interop effort. Would it be easier to incorporate into the testsuite if this were not a hidden bug?
Thank you for awesome explanation
![]() |
||
Comment 7•1 year ago
|
||
Reporter | ||
Comment 8•1 year ago
|
||
It's good to know that the bug I reported has been resolved. I would like to know, does the bug I reported qualify for a bounty?
Updated•1 year ago
|
Comment 9•1 year ago
|
||
Congratulations: we are awarding a bug bounty for this bug.
Reporter | ||
Comment 10•1 year ago
|
||
Thank you ! 😁
Updated•1 year ago
|
Updated•1 year ago
|
Comment 11•1 year ago
|
||
Please nominate this for ESR115 approval when you get a chance.
Assignee | ||
Comment 12•1 year ago
|
||
Comment on attachment 9358032 [details]
Bug 1858570 - Fix relative URL path starting with multiple slashes r=#necko
ESR Uplift Approval Request
- If this is not a sec:{high,crit} bug, please state case for ESR consideration: Possible incorrect parsing of scheme relative URLs
- User impact if declined: As noted in comment 1, Firefox might incorrectly replace the hostname of the parsed URL with a path segment
- Fix Landed on Version: 120
- Risk to taking this patch: Low
- Why is the change risky/not risky? (and alternatives if risky): This change makes it so that we skip multiple slashes after :// when coalescing the directory of the path so that we do not inadvertently change the hostname.
Assignee | ||
Updated•1 year ago
|
Updated•1 year ago
|
Comment 13•1 year ago
|
||
Verified as fixed on Firefox 121.0a1 (2023-11-06) and Firefox 120.0b6 on macOS 11.6, Windows 10 x64 and on Ubuntu 20.04.
Updated•1 year ago
|
Comment 14•1 year ago
|
||
Comment on attachment 9358032 [details]
Bug 1858570 - Fix relative URL path starting with multiple slashes r=#necko
Approved for 115.5esr.
Comment 15•1 year ago
|
||
uplift |
Updated•1 year ago
|
Comment 16•1 year ago
|
||
Verified as fixed on Firefox 1115.5.0esr (treeherder build) on macOS 11.6, Windows 10 x64 and on Ubuntu 20.04.
Updated•1 year ago
|
Comment 17•1 year ago
|
||
Updated•1 year ago
|
Comment 18•1 year ago
|
||
![]() |
||
Comment 19•1 year ago
|
||
Comment 20•10 months ago
|
||
Bulk-unhiding security bugs fixed in Firefox 119-121 (Fall 2023). Use "moo-doctrine-subsidy" to filter
Updated•8 months ago
|
Description
•