Skip to content

Commit e3d0e9f

Browse files
committed
Update normalized path node
1 parent 12c53ba commit e3d0e9f

File tree

2 files changed

+7
-9
lines changed

2 files changed

+7
-9
lines changed

java/ql/src/experimental/Security/CWE/CWE-073/FilePathInjection.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class InjectFilePathConfig extends TaintTracking::Configuration {
2525

2626
override predicate isSink(DataFlow::Node sink) {
2727
sink.asExpr() = any(PathCreation p).getAnInput() and
28-
not sink instanceof SanitizedNode
28+
not sink instanceof NormalizedPathNode
2929
}
3030

3131
override predicate isSanitizer(DataFlow::Node node) {

java/ql/src/experimental/Security/CWE/CWE-073/PathSanitizer.qll

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -174,12 +174,10 @@ private class UrlDecodeSanitizer extends MethodAccess {
174174
}
175175
}
176176

177-
/** A sanitized node that is protected against path traversal vulnerabilities. */
178-
abstract class SanitizedNode extends DataFlow::Node { }
179-
180-
class NodeWithPathNormalizer extends SanitizedNode {
181-
NodeWithPathNormalizer() {
182-
DataFlow::localExprFlow(this.asExpr(), any(PathNormalizeSanitizer ma))
177+
/** A node with path normalization. */
178+
class NormalizedPathNode extends DataFlow::Node {
179+
NormalizedPathNode() {
180+
TaintTracking::localExprTaint(this.asExpr(), any(PathNormalizeSanitizer ma))
183181
}
184182
}
185183

@@ -188,8 +186,8 @@ private class PathDataModel extends SummaryModelCsv {
188186
override predicate row(string row) {
189187
row =
190188
[
191-
"java.nio.file;Paths;true;get;;;Argument[0];ReturnValue;value",
192-
"java.nio.file;Path;true;normalize;;;Argument[-1];ReturnValue;value"
189+
"java.nio.file;Paths;true;get;;;Argument[0];ReturnValue;taint",
190+
"java.nio.file;Path;true;normalize;;;Argument[-1];ReturnValue;taint"
193191
]
194192
}
195193
}

0 commit comments

Comments
 (0)