Skip to content

Commit a167577

Browse files
committed
Java: Add java.lang.Number as a sanitizer for SQL injection.
1 parent d0ac846 commit a167577

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

java/ql/src/Security/CWE/CWE-089/SqlInjectionLib.qll

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,9 @@ private class QueryInjectionFlowConfig extends TaintTracking::Configuration {
5454
override predicate isSink(DataFlow::Node sink) { sink instanceof QueryInjectionSink }
5555

5656
override predicate isSanitizer(DataFlow::Node node) {
57-
node.getType() instanceof PrimitiveType or node.getType() instanceof BoxedType
57+
node.getType() instanceof PrimitiveType or
58+
node.getType() instanceof BoxedType or
59+
node.getType() instanceof NumberType
5860
}
5961
}
6062

java/ql/src/semmle/code/java/JDK.qll

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,16 @@ class TypeMath extends Class {
101101
TypeMath() { this.hasQualifiedName("java.lang", "Math") }
102102
}
103103

104+
/** The class `java.lang.Number`. */
105+
class TypeNumber extends RefType {
106+
TypeNumber() { this.hasQualifiedName("java.lang", "Number") }
107+
}
108+
109+
/** A (reflexive, transitive) subtype of `java.lang.Number`. */
110+
class NumberType extends RefType {
111+
NumberType() { exists(TypeNumber number | hasSubtype*(number, this)) }
112+
}
113+
104114
/** A numeric type, including both primitive and boxed types. */
105115
class NumericType extends Type {
106116
NumericType() {

0 commit comments

Comments
 (0)