Skip to content

Commit cf33db7

Browse files
committed
JS: Fix the spurious flow
1 parent c051b4c commit cf33db7

2 files changed

Lines changed: 5 additions & 2 deletions

File tree

  • javascript/ql

javascript/ql/lib/semmle/javascript/frameworks/SQL.qll

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,10 @@ private module Postgres {
221221

222222
/** Gets a value that is plugged into a raw placeholder variable, making it a sink for SQL injection. */
223223
private DataFlow::Node getARawValue() {
224-
result = this.getValues() and this.getARawParameterName() = "1" // Special case: if the argument is not an array or object, it's just plugged into $1
224+
result = this.getValues() and
225+
this.getARawParameterName() = "1" and // Special case: if the argument is not an array or object, it's just plugged into $1
226+
not result instanceof DataFlow::ArrayCreationNode and
227+
not result instanceof DataFlow::ObjectLiteralNode
225228
or
226229
exists(DataFlow::SourceNode values | values = this.getValues().getALocalSource() |
227230
result = values.getAPropertyWrite(this.getARawParameterName()).getRhs()

javascript/ql/test/query-tests/Security/CWE-089/untyped/pg-promise.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ require('express')().get('/foo', (req, res) => {
3939
req.params.id, // $ Alert
4040
req.params.name, // $ Alert
4141
req.params.foo, // OK - not using raw interpolation
42-
] // $ SPURIOUS: Alert - implicit reads causes flow here in addition to the individual array elements
42+
]
4343
});
4444
db.one({
4545
text: 'SELECT * FROM news where id = ${id}:raw AND name = ${name}',

0 commit comments

Comments
 (0)