Skip to content

Commit fa58c51

Browse files
committed
Ruby: switch rb/sensitive-get-query back to using local flow
1 parent 71670a4 commit fa58c51

File tree

4 files changed

+27
-106
lines changed

4 files changed

+27
-106
lines changed

ruby/ql/lib/codeql/ruby/security/SensitiveGetQueryCustomizations.qll

Lines changed: 0 additions & 54 deletions
This file was deleted.

ruby/ql/lib/codeql/ruby/security/SensitiveGetQueryQuery.qll

Lines changed: 0 additions & 31 deletions
This file was deleted.

ruby/ql/src/queries/security/cwe-598/SensitiveGetQuery.ql

Lines changed: 26 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* @name Sensitive data read from GET request
33
* @description Placing sensitive data in a GET request increases the risk of
44
* the data being exposed to an attacker.
5-
* @kind path-problem
5+
* @kind problem
66
* @problem.severity warning
77
* @security-severity 6.5
88
* @precision high
@@ -12,12 +12,30 @@
1212
*/
1313

1414
import ruby
15-
import DataFlow::PathGraph
16-
import codeql.ruby.security.SensitiveGetQueryQuery
15+
import codeql.ruby.Concepts
1716
import codeql.ruby.security.SensitiveActions
1817

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"
Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1 @@
1-
edges
2-
| app/controllers/users_controller.rb:4:16:4:21 | call to params : | app/controllers/users_controller.rb:4:16:4:32 | ...[...] |
3-
| app/controllers/users_controller.rb:4:16:4:21 | call to params : | app/controllers/users_controller.rb:4:16:4:32 | ...[...] : |
4-
| app/controllers/users_controller.rb:4:16:4:32 | ...[...] : | app/controllers/users_controller.rb:5:42:5:49 | password |
5-
nodes
6-
| app/controllers/users_controller.rb:4:16:4:21 | call to params : | semmle.label | call to params : |
7-
| app/controllers/users_controller.rb:4:16:4:32 | ...[...] | semmle.label | ...[...] |
8-
| app/controllers/users_controller.rb:4:16:4:32 | ...[...] : | semmle.label | ...[...] : |
9-
| app/controllers/users_controller.rb:5:42:5:49 | password | semmle.label | password |
10-
subpaths
11-
#select
12-
| app/controllers/users_controller.rb:4:16:4:21 | call to params | app/controllers/users_controller.rb:4:16:4:21 | call to params : | app/controllers/users_controller.rb:4:16:4:32 | ...[...] | $@ for GET requests uses query parameter as sensitive data. | app/controllers/users_controller.rb:3:3:6:5 | login_get | Route handler |
13-
| app/controllers/users_controller.rb:4:16:4:21 | call to params | app/controllers/users_controller.rb:4:16:4:21 | call to params : | app/controllers/users_controller.rb:5:42:5:49 | password | $@ for GET requests uses query parameter as sensitive data. | app/controllers/users_controller.rb:3:3:6:5 | login_get | Route handler |
1+
| app/controllers/users_controller.rb:4:16:4:21 | call to params | $@ for GET requests uses query parameter as sensitive data. | app/controllers/users_controller.rb:3:3:6:5 | login_get | Route handler |

0 commit comments

Comments
 (0)