-
Notifications
You must be signed in to change notification settings - Fork 2k
Expand file tree
/
Copy pathSensitiveGetQuery.ql
More file actions
43 lines (40 loc) · 1.43 KB
/
SensitiveGetQuery.ql
File metadata and controls
43 lines (40 loc) · 1.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
/**
* @name Sensitive data read from GET request
* @description Placing sensitive data in a GET request increases the risk of
* the data being exposed to an attacker.
* @kind problem
* @problem.severity warning
* @security-severity 6.5
* @precision high
* @id rb/sensitive-get-query
* @tags security
* external/cwe/cwe-598
*/
import ruby
private import codeql.ruby.DataFlow
private import codeql.ruby.security.SensitiveActions
private import codeql.ruby.Concepts
private import codeql.ruby.frameworks.ActionDispatch
private import codeql.ruby.frameworks.ActionController
private import codeql.ruby.frameworks.core.Array
// Local flow augmented with flow through element references
private predicate localFlowWithElementReference(DataFlow::LocalSourceNode src, DataFlow::Node to) {
src.flowsTo(to)
or
exists(DataFlow::Node midRecv, DataFlow::LocalSourceNode mid, ElementReference ref |
src.flowsTo(midRecv) and
midRecv.asExpr().getExpr() = ref.getReceiver() and
mid.asExpr().getExpr() = ref
|
localFlowWithElementReference(mid, to)
)
}
from
HTTP::Server::RequestHandler handler, HTTP::Server::RequestInputAccess input,
SensitiveNode sensitive
where
handler.getAnHttpMethod() = "get" and
input.asExpr().getExpr().getEnclosingMethod() = handler and
localFlowWithElementReference(input, sensitive)
select input, "$@ for GET requests uses query parameter as sensitive data.", handler,
"Route handler"