Skip to content

Commit d6ae905

Browse files
committed
JS: remove speculative property access sink from js/server-crash
1 parent 1d39652 commit d6ae905

3 files changed

Lines changed: 2 additions & 19 deletions

File tree

javascript/ql/src/Security/CWE-730/ServerCrash.ql

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -36,15 +36,6 @@ predicate isHeaderValue(HTTP::ExplicitHeaderDefinition def, DataFlow::Node node)
3636
def.definesExplicitly(_, node.asExpr())
3737
}
3838

39-
predicate isDangerousPropertyRead(DataFlow::PropRead read) {
40-
// TODO use flow labels
41-
exists(DataFlow::PropRead base |
42-
base = read.getBase() and
43-
not read instanceof RemoteFlowSource and
44-
not exists(read.getACall())
45-
)
46-
}
47-
4839
class Configuration extends TaintTracking::Configuration {
4940
Configuration() { this = "Configuration" }
5041

@@ -53,18 +44,11 @@ class Configuration extends TaintTracking::Configuration {
5344
override predicate isSink(DataFlow::Node node) {
5445
// using control characters in a header value will cause an exception
5546
isHeaderValue(_, node)
56-
or
57-
// accessing a property of undefined will cause an exception
58-
isDangerousPropertyRead(node)
5947
}
6048
}
6149

6250
predicate isLikelyToThrow(DataFlow::Node crash) {
63-
exists(Configuration cfg, DataFlow::Node sink | cfg.hasFlow(_, sink) |
64-
isHeaderValue(crash, sink)
65-
or
66-
isDangerousPropertyRead(sink) and sink = crash
67-
)
51+
exists(Configuration cfg, DataFlow::Node sink | cfg.hasFlow(_, sink) | isHeaderValue(crash, sink))
6852
}
6953

7054
/**

javascript/ql/test/query-tests/Security/CWE-730/ServerCrash.expected

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,3 @@
44
| server-crash.js:28:5:28:14 | throw err; | When an exception is thrown here and later exits $@, the server of $@ will crash. | server-crash.js:27:28:29:3 | (err, x ... OK\\n } | an asynchronous function | server-crash.js:31:25:73:1 | (req, r ... });\\n} | this route handler |
55
| server-crash.js:33:5:33:14 | throw err; | When an exception is thrown here and later exits $@, the server of $@ will crash. | server-crash.js:32:28:34:3 | (err, x ... OK\\n } | an asynchronous function | server-crash.js:31:25:73:1 | (req, r ... });\\n} | this route handler |
66
| server-crash.js:41:5:41:48 | res.set ... header) | When an exception is thrown here and later exits $@, the server of $@ will crash. | server-crash.js:40:28:42:3 | (err, x ... OK\\n } | an asynchronous function | server-crash.js:31:25:73:1 | (req, r ... });\\n} | this route handler |
7-
| server-crash.js:68:5:68:21 | req.query.foo.bar | When an exception is thrown here and later exits $@, the server of $@ will crash. | server-crash.js:67:28:69:3 | (err, x ... OK\\n } | an asynchronous function | server-crash.js:31:25:73:1 | (req, r ... });\\n} | this route handler |

javascript/ql/test/query-tests/Security/CWE-730/server-crash.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ app.get("/async-throw", (req, res) => {
6565
});
6666

6767
fs.readFile("/WHATEVER", (err, x) => {
68-
req.query.foo.bar; // NOT OK
68+
req.query.foo.bar; // NOT OK [INCONSISTENCY]: need to add property reads as sinks
6969
});
7070
fs.readFile("/WHATEVER", (err, x) => {
7171
res.setHeader("reflected", unknown); // OK

0 commit comments

Comments
 (0)