Repository navigation
Do not send the credentials of the page url in the Referer and Origin headers - #1203
Merged
Merged
Conversation
WebRequest.setRefererHeader() and the origin helpers UrlUtils.getUrlWithProtocolAndAuthority() / getUrlWithoutPathRefQuery() copied URL.getAuthority(), which includes the user info. A page loaded from http://user:password@host/ sent the credentials in the Referer and Origin headers to every site it referenced, and they showed up in document.referrer, MessageEvent.origin and the WebSocket Origin. The referrer is stripped of username and password (Fetch standard, strip url for use as a referrer) and an origin has no user info.
|
Member
|
made a new snapshot build available |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



The credentials of the page url leak through Referer and Origin
WebRequest.setRefererHeader()and the origin helpersUrlUtils.getUrlWithProtocolAndAuthority()/getUrlWithoutPathRefQuery()copyURL.getAuthority(), which includes the user info. A page loaded fromhttp://admin:s3cret@intranet.example/app/that submits a form tohttp://evil.example/collectsendsReferer: http://admin:s3cret@intranet.example/app/andOrigin: http://admin:s3cret@intranet.example. The same happens for every link, image, script, stylesheet, iframe, ping and sendBeacon the page triggers, and the credentials also end up indocument.referrerof the target page, inMessageEvent.originof postMessage and in the Origin of WebSocket handshakes. The Fetch standard strips username and password from the referrer ("strip url for use as a referrer") and an origin has no user info, so browsers never send them. Urls without user info produce exactly the same string as before.WebRequestTest.refererHeaderWithoutCredentialsand the newUrlUtilsTestcases fail on master and pass with the change. I also checked the form submit case end to end with a MockWebConnection: both headers now carry onlyhttp://intranet.example. The WebRequest, UrlUtils, anchor/form/image/link/script, Location, Window, XMLHttpRequest, WebSocket, WebClient and CodeStyle tests show no new failures (only the existing DNS-dependent and timing-sensitive ones that fail here on master too), and checkstyle and pmd are clean. I also added a changes.xml entry.