Skip to content

Commit dc26bdc

Browse files
committed
JS: Move isThirdPartyControllable into RequestInputAccess
1 parent 271b2f3 commit dc26bdc

File tree

4 files changed

+21
-20
lines changed

4 files changed

+21
-20
lines changed

javascript/ql/src/semmle/javascript/frameworks/HTTP.qll

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -400,7 +400,20 @@ module HTTP {
400400
*/
401401
abstract string getKind();
402402

403-
override predicate isThirdPartyControllable() {
403+
/**
404+
* Holds if this part of the request may be controlled by a third party,
405+
* that is, an agent other than the one who sent the request.
406+
*
407+
* This is true for the URL, query parameters, and request body.
408+
* These can be controlled by a malicious third party in the following scenarios:
409+
*
410+
* - The user clicks a malicious link or is otherwise redirected to a malicious URL.
411+
* - The user visits a web site that initiates a form submission or AJAX request on their behalf.
412+
*
413+
* In these cases, the request is technically sent from the user's browser, but
414+
* the user is not in direct control of the URL or POST body.
415+
*/
416+
predicate isThirdPartyControllable() {
404417
exists (string kind | kind = getKind() |
405418
kind = "parameter" or
406419
kind = "url" or

javascript/ql/src/semmle/javascript/security/dataflow/ReflectedXss.qll

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,10 @@ module ReflectedXss {
4343
}
4444
}
4545

46-
/** A source of remote user input, considered as a flow source for reflected XSS. */
47-
class RemoteFlowSourceAsSource extends Source {
48-
RemoteFlowSourceAsSource() {
49-
this.(RemoteFlowSource).isThirdPartyControllable()
46+
/** A third-party controllable request input, considered as a flow source for reflected XSS. */
47+
class ThirdPartyRequestInputAccessAsSource extends Source {
48+
ThirdPartyRequestInputAccessAsSource() {
49+
this.(HTTP::RequestInputAccess).isThirdPartyControllable()
5050
}
5151
}
5252

javascript/ql/src/semmle/javascript/security/dataflow/RemoteFlowSources.qll

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,6 @@ import semmle.javascript.security.dataflow.DOM
1010
abstract class RemoteFlowSource extends DataFlow::Node {
1111
/** Gets a string that describes the type of this remote flow source. */
1212
abstract string getSourceType();
13-
14-
/**
15-
* Holds if this flow source comes from an incoming request, and this part of the
16-
* request can be controlled by a third party, that is, an actor other than the one
17-
* sending the request.
18-
*
19-
* Any web site can redirect the visitor's browser to any other domain, and in doing so control
20-
* the entire URL and POST body. In this scenario, these values are technically sent by the
21-
* user's browser, but the user is not in direct control of these values, so they are considered
22-
* third-party controllable.
23-
*/
24-
predicate isThirdPartyControllable() { none() }
2513
}
2614

2715
/**

javascript/ql/src/semmle/javascript/security/dataflow/ServerSideUrlRedirect.qll

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,9 @@ module ServerSideUrlRedirect {
9191
}
9292

9393
/** A source of third-party user input, considered as a flow source for URL redirects. */
94-
class RemoteFlowSourceAsSource extends Source {
95-
RemoteFlowSourceAsSource() {
96-
this.(RemoteFlowSource).isThirdPartyControllable()
94+
class ThirdPartyRequestInputAccessAsSource extends Source {
95+
ThirdPartyRequestInputAccessAsSource() {
96+
this.(HTTP::RequestInputAccess).isThirdPartyControllable()
9797
}
9898
}
9999

0 commit comments

Comments
 (0)