From 1bc73ab59244b7e560456b73ab3f94d42862f96d Mon Sep 17 00:00:00 2001
From: Esben Sparre Andreasen
wwwXexample.com.
Address this vulnerability by escaping .
- appropriately: let regex =/(www|beta|)\.example\.com/.
+ appropriately: let regex = /(www|beta|)\.example\.com/.
diff --git a/javascript/ql/src/Security/CWE-020/IncompleteHostnameRegExp.ql b/javascript/ql/src/Security/CWE-020/IncompleteHostnameRegExp.ql
index 49344ee8fec..abe6d76d6f0 100644
--- a/javascript/ql/src/Security/CWE-020/IncompleteHostnameRegExp.ql
+++ b/javascript/ql/src/Security/CWE-020/IncompleteHostnameRegExp.ql
@@ -12,28 +12,25 @@
import javascript
-module IncompleteHostnameRegExpTracking {
+/**
+ * A taint tracking configuration for incomplete hostname regular expressions sources.
+ */
+class Configuration extends TaintTracking::Configuration {
+ Configuration() { this = "IncompleteHostnameRegExpTracking" }
- /**
- * A taint tracking configuration for incomplete hostname regular expressions sources.
- */
- class Configuration extends TaintTracking::Configuration {
- Configuration() { this = "IncompleteHostnameRegExpTracking" }
-
- override
- predicate isSource(DataFlow::Node source) {
- isIncompleteHostNameRegExpPattern(source.asExpr().getStringValue(), _)
- }
-
- override
- predicate isSink(DataFlow::Node sink) {
- isInterpretedAsRegExp(sink)
- }
+ override
+ predicate isSource(DataFlow::Node source) {
+ isIncompleteHostNameRegExpPattern(source.asExpr().getStringValue(), _)
+ }
+ override
+ predicate isSink(DataFlow::Node sink) {
+ isInterpretedAsRegExp(sink)
}
}
+
/**
* Holds if `pattern` is a regular expression pattern for URLs with a host matched by `hostPart`,
* and `pattern` contains a subtle mistake that allows it to match unexpected hosts.
@@ -45,7 +42,7 @@ predicate isIncompleteHostNameRegExpPattern(string pattern, string hostPart) {
// an unescaped single `.`
"(?>
+ result = "com|org|edu|gov|uk|net|io"
+ }
+}
\ No newline at end of file