-
Notifications
You must be signed in to change notification settings - Fork 1.7k
/
Copy pathSqlInjection.ql
36 lines (32 loc) · 1.32 KB
/
SqlInjection.ql
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
/**
* @name Database query built from user-controlled sources
* @description Building a database query from user-controlled sources is vulnerable to insertion of
* malicious code by the user.
* @kind path-problem
* @problem.severity error
* @security-severity 8.8
* @precision high
* @id js/sql-injection
* @tags security
* external/cwe/cwe-089
* external/cwe/cwe-090
* external/cwe/cwe-943
*/
import javascript
import semmle.javascript.security.dataflow.SqlInjectionQuery as Sql
import semmle.javascript.security.dataflow.NosqlInjectionQuery as Nosql
module Merged =
DataFlow::MergePathGraph<Sql::SqlInjectionFlow::PathNode, Nosql::NosqlInjectionFlow::PathNode,
Sql::SqlInjectionFlow::PathGraph, Nosql::NosqlInjectionFlow::PathGraph>;
import DataFlow::DeduplicatePathGraph<Merged::PathNode, Merged::PathGraph>
from PathNode source, PathNode sink, string type
where
Sql::SqlInjectionFlow::flowPath(source.getAnOriginalPathNode().asPathNode1(),
sink.getAnOriginalPathNode().asPathNode1()) and
type = "string"
or
Nosql::NosqlInjectionFlow::flowPath(source.getAnOriginalPathNode().asPathNode2(),
sink.getAnOriginalPathNode().asPathNode2()) and
type = "object"
select sink.getNode(), source, sink, "This query " + type + " depends on a $@.", source.getNode(),
"user-provided value"