Closed Bug 1263627 Opened 9 years ago Closed 9 years ago

It should not be possible to manually navigate to internal URLs

Categories

(Firefox for iOS :: General, defect)

Other
iOS
defect
Not set
critical

Tracking

()

RESOLVED FIXED
Tracking Status
fxios 4.0+ ---
fxios-v4.0 --- fixed
fxios-v5.0 --- fixed

People

(Reporter: st3fan, Assigned: bnicholson)

References

Details

Attachments

(1 file, 1 obsolete file)

We have a number of 'internal' URLs that are hosted on localhost. It should not be possible to navigate to these URLs manually or through JavaScript. Ideally all these URLs have some form of CSRF protection, like including a secret random token in the request. That will prevent people from being able to manually call these internal endpoints.
Severity: normal → critical
Rank: 1
Assignee: nobody → bnicholson
Status: NEW → ASSIGNED
Attachment #8741975 - Attachment is obsolete: true
Attachment #8741975 - Flags: review?(sarentz)
Attachment #8741980 - Flags: review?(sarentz)
Note that there's still a tricky case this bug doesn't handle: links from reader mode. Filed bug 1265115.
This looks good. I would just like to see a unit (or UI) test that shows that these loads are now failing.
Comment on attachment 8741980 [details] [review] Link to Github pull-request: https://github.com/mozilla/firefox-ios/pull/1725 LGTM Just needs a test. If the test needs to run against an external site, maybe just move it to a separate LiveTests case so that that we can control when it runs?
Attachment #8741980 - Flags: review?(sarentz) → review+
Added a test in the PR. Unfortunately, I don't think this is ready yet after more testing. In addition to bug 1265115 mentioned above, there's another tricky exploit: 1) Use window.open() to go to some invalid URL. 2) This will load an error page. 3) With the reference to this opened window, set win.location.href to the malicious sessionrestore URL. Like bug 1265115, this exploits the fact that requests from localhost pages are allowed to load other localhost pages. To fix this properly, I think we'll want to remove that rule, meaning localhost pages will be treated the same as any other page. That means if we want to access local pages from other local pages (which we currently need for error pages, session restore, etc.), we'll have to route these requests through messages to Swift, where we can then create explicit PrivilegedRequests.
Attachment #8741980 - Flags: review+
PoC of exploit from comment 6: https://people.mozilla.org/~bnicholson/test/localhost-nav-test.html Use the "window error + session test" button.
Comment on attachment 8741980 [details] [review] Link to Github pull-request: https://github.com/mozilla/firefox-ios/pull/1725 Updated with stricter requirements and tests. Now, no pages (including local ones) will be able load other local pages directly; the only way to load anything on localhost is through PrivilegedRequest. That means if local pages want to load another URL or even reload the current page, they'll have to funnel that request through the Swift layer to make the request privileged. I created a shared LocalRequestHelper to handle these messages.
Attachment #8741980 - Flags: review?(sarentz)
Comment on attachment 8741980 [details] [review] Link to Github pull-request: https://github.com/mozilla/firefox-ios/pull/1725 This is a great patch. I left a few comments though.
Attachment #8741980 - Flags: review?(sarentz) → review+
Status: ASSIGNED → RESOLVED
Closed: 9 years ago
Resolution: --- → FIXED
Depends on: 1267482
See Also: → 1279787
Depends on: 1281204
Depends on: 1282887
Depends on: 1282929
See Also: → CVE-2023-49060
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: