-
Notifications
You must be signed in to change notification settings - Fork 1.9k
JS: add RemoteFlowSource.isThirdPartyControllable() #273
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Use it in ReflectedXSS and ServerSideURrlRedirect
xiemaisi
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree with the overall goal of this PR, but I'm wondering whether we should perhaps go about it slightly differently as suggested in the comments.
| * request can be controlled by a third party, that is, an actor other than the one | ||
| * sending the request. | ||
| * | ||
| * Any web site can redirect the visitor's browser to any other domain, and in doing so control |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand this explanation, particularly the bit beginning with "and in doing so". Why is it important what the web site controls? Aren't we more interested in what data the remote user/attacker controls?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The web site is the attacker here. Would the following change clarify things?
A malicious web site can redirect the visitor's browser to any other domain [...]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The goal of the paragraph is to explain why a user might sent a request with data he doesn't control, and why it's not okay to just blame for user for sending stupid requests that compromise his account.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I think that would be clearer.
| } | ||
|
|
||
| /** | ||
| * Holds if this flow source comes from an incoming request, and this part of the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This sounds too special-case to put it on a fairly general class like RemoteFlowSource. Is there a more general way to describe this scenario independent of the specifics of HTTP requests? Or should we perhaps only have this predicate on RequestInputAccess and specialise the sources of ReflectedXSS and ServerSideUrlRedirect to be request input accesses? (I don't think any of the other remote flow sources are relevant for those two queries, but it's of course worth checking.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Originally I wanted to describe it more generally as something like:
Holds if data from this source may be controlled by an actor other than the one who sent it.
However, now we have to decide how to classify browser-side sources like document.location. Who sent this data? By what definition is this even a "remote" flow source?
On one hand, one could argue that they were "sent" to the user by another web server from where the user was redirected (most CSRF attacks essentially start that way). From that viewpoint, they are indeed controlled by the sender of the data (the malicious web site), thus is not third-party controlled.
On the other hand, one could argue that any flow source of interest on the browser-side must come from a third party because the client trusts both himself and the server. Thus one would expect to use isThirdPartyControllable() in DomBasedXss and ClientSideUrlRedirect.
In any case, it was sufficiently non-obvious how to classify document.location, and that's why I opted for a definition that's less ambiguous.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like you suggestion on moving it into RequestInputAccess, as that's essentially the same as saying it must be an "incoming request" (albeit restricted to HTTP requests).
|
I've moved it into |
xiemaisi
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
…-test Add test showing assign expressions
Sync Main (autogenerated)
Adds
isThirdPartyControllable()predicate toRemoteFlowSourcefor flow sources that can be controlled by the attacker during CSRF.ReflectedXSS and ServerSideUrlRedirect have been updated to use this. This eliminates some false positives.
The CorsMisconfiguration query is a bit of a conundrum. It is certainly in the CSRF category, but is different from the others in that the tracks values that may refer to a foreign URL. Most importantly, this includes the
Originheader, which is may refer to a malicious web site, but is not otherwise directly controlled by the attacker. I see three options for how to approach this:Originheader, and maybe theRefererheader.isThirdPartyControllable()to includeOriginandRefererheaders. Technically you could have a reflected XSS through the referer header, and a server-side URL redirect to the referer could cause information leak if a secret session/auth token is appended in the URL.So far this PR just uses option 3, but I'd like to hear your opinion on this. I haven't seen any concrete results that could motivate one choice over another.