Skip to content

Commit 0249187

Browse files
committed
Add ExternallyControlledFormatStringLocalQuery.qll
1 parent 5834e4a commit 0249187

File tree

3 files changed

+23
-15
lines changed

3 files changed

+23
-15
lines changed

java/ql/lib/change-notes/2023-03-30-add-libraries-for-query-configurations.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,5 @@ category: minorAnalysis
44
* Added the `TaintedPermissionQuery.qll` library to provide the `TaintedPermissionFlow` taint-tracking module to reason about tainted permission vulnerabilities.
55
* Added the `XPathInjectionQuery.qll` library to provide the `XPathInjectionFlow` taint-tracking module to reason about XPath injection vulnerabilities.
66
* Added the `SqlConcatenatedQuery.qll` library to provide the `UncontrolledStringBuilderSourceFlow` taint-tracking module to reason about SQL injection vulnerabilities caused by concatenating untrusted strings.
7-
* Added the `XssLocalQuery.qll` library to provide the `XssLocalFlow` taint-tracking module to reason about XSS vulnerabilities caused by local data flow.
7+
* Added the `XssLocalQuery.qll` library to provide the `XssLocalFlow` taint-tracking module to reason about XSS vulnerabilities caused by local data flow.
8+
* Added the `ExternallyControlledFormatStringLocalQuery.qll` library to provide the `ExternallyControlledFormatStringLocalFlow` taint-tracking module to reason about format string vulnerabilities caused by local data flow.
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/** Provides a taint-tracking configuration to reason about externally-controlled format strings from local sources. */
2+
3+
import java
4+
import semmle.code.java.dataflow.FlowSources
5+
import semmle.code.java.StringFormat
6+
7+
/** A taint-tracking configuration to reason about externally-controlled format strings from local sources. */
8+
module ExternallyControlledFormatStringLocalConfig implements DataFlow::ConfigSig {
9+
predicate isSource(DataFlow::Node source) { source instanceof LocalUserInput }
10+
11+
predicate isSink(DataFlow::Node sink) {
12+
sink.asExpr() = any(StringFormat formatCall).getFormatArgument()
13+
}
14+
}
15+
16+
/**
17+
* Taint-tracking flow for externally-controlled format strings from local sources.
18+
*/
19+
module ExternallyControlledFormatStringLocalFlow =
20+
TaintTracking::Global<ExternallyControlledFormatStringLocalConfig>;

java/ql/src/Security/CWE/CWE-134/ExternallyControlledFormatStringLocal.ql

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -11,20 +11,7 @@
1111
*/
1212

1313
import java
14-
import semmle.code.java.dataflow.FlowSources
15-
import semmle.code.java.StringFormat
16-
17-
module ExternallyControlledFormatStringLocalConfig implements DataFlow::ConfigSig {
18-
predicate isSource(DataFlow::Node source) { source instanceof LocalUserInput }
19-
20-
predicate isSink(DataFlow::Node sink) {
21-
sink.asExpr() = any(StringFormat formatCall).getFormatArgument()
22-
}
23-
}
24-
25-
module ExternallyControlledFormatStringLocalFlow =
26-
TaintTracking::Global<ExternallyControlledFormatStringLocalConfig>;
27-
14+
import semmle.code.java.security.ExternallyControlledFormatStringLocalQuery
2815
import ExternallyControlledFormatStringLocalFlow::PathGraph
2916

3017
from

0 commit comments

Comments
 (0)