|
2 | 2 | * @name Sensitive data read from GET request
|
3 | 3 | * @description Placing sensitive data in a GET request increases the risk of
|
4 | 4 | * the data being exposed to an attacker.
|
5 |
| - * @kind path-problem |
| 5 | + * @kind problem |
6 | 6 | * @problem.severity warning
|
7 | 7 | * @security-severity 6.5
|
8 | 8 | * @precision high
|
|
12 | 12 | */
|
13 | 13 |
|
14 | 14 | import ruby
|
15 |
| -import DataFlow::PathGraph |
16 |
| -import codeql.ruby.security.SensitiveGetQueryQuery |
| 15 | +import codeql.ruby.Concepts |
17 | 16 | import codeql.ruby.security.SensitiveActions
|
18 | 17 |
|
19 |
| -from DataFlow::PathNode source, DataFlow::PathNode sink, SensitiveGetQuery::Configuration config |
20 |
| -where config.hasFlowPath(source, sink) |
21 |
| -select source.getNode(), source, sink, |
22 |
| - "$@ for GET requests uses query parameter as sensitive data.", |
23 |
| - source.getNode().(SensitiveGetQuery::Source).getHandler(), "Route handler" |
| 18 | +// Local flow augmented with flow through element references |
| 19 | +private predicate localFlowWithElementReference(DataFlow::LocalSourceNode src, DataFlow::Node to) { |
| 20 | + src.flowsTo(to) |
| 21 | + or |
| 22 | + exists(DataFlow::Node midRecv, DataFlow::LocalSourceNode mid, Ast::ElementReference ref | |
| 23 | + src.flowsTo(midRecv) and |
| 24 | + midRecv.asExpr().getExpr() = ref.getReceiver() and |
| 25 | + mid.asExpr().getExpr() = ref |
| 26 | + | |
| 27 | + localFlowWithElementReference(mid, to) |
| 28 | + ) |
| 29 | +} |
| 30 | + |
| 31 | +from |
| 32 | + Http::Server::RequestHandler handler, Http::Server::RequestInputAccess input, |
| 33 | + SensitiveNode sensitive |
| 34 | +where |
| 35 | + handler.getAnHttpMethod() = "get" and |
| 36 | + input.asExpr().getExpr().getEnclosingMethod() = handler and |
| 37 | + input.getKind() = "parameter" and |
| 38 | + localFlowWithElementReference(input, sensitive) and |
| 39 | + not sensitive.getClassification() = SensitiveDataClassification::id() |
| 40 | +select input, "$@ for GET requests uses query parameter as sensitive data.", handler, |
| 41 | + "Route handler" |
0 commit comments