Skip to content

Commit e164f46

Browse files
committed
changes based on review feedback
1 parent f35dc5d commit e164f46

3 files changed

Lines changed: 15 additions & 8 deletions

File tree

javascript/ql/src/semmle/javascript/dataflow/Configuration.qll

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,6 @@ abstract class BarrierGuardNode extends DataFlow::Node {
303303
*
304304
* INTERNAL: this predicate should only be used from within `blocks(boolean, Expr)`.
305305
*/
306-
pragma[noinline,nomagic]
307306
predicate internalBlocks(DataFlow::Node nd, string label) {
308307
// 1) `nd` is a use of a refinement node that blocks its input variable
309308
exists(SsaRefinementNode ref, boolean outcome |

javascript/ql/src/semmle/javascript/security/dataflow/ExceptionXss.qll

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
*/
66

77
import javascript
8-
import Statements.UselessConditional
98

109
module ExceptionXss {
1110
import DomBasedXssCustomizations::DomBasedXss as DomBasedXssCustom
@@ -48,7 +47,7 @@ module ExceptionXss {
4847
node.asExpr().getEnclosingStmt() instanceof ThrowStmt
4948
or
5049
exists(DataFlow::PropRef prop |
51-
node.getEnclosingExpr() = prop.getPropertyNameExpr() and
50+
node = DataFlow::valueNode(prop.getPropertyNameExpr()) and
5251
isNullOrUndefined(prop.getBase().analyze().getAType())
5352
)
5453
)
@@ -70,15 +69,15 @@ module ExceptionXss {
7069
*/
7170
class Callback extends DataFlow::FunctionNode {
7271
DataFlow::ParameterNode errorParameter;
72+
IfStmt ifStmt;
7373

7474
Callback() {
7575
exists(DataFlow::CallNode call | call.getLastArgument().getAFunctionValue() = this) and
7676
this.getNumParameter() = 2 and
7777
errorParameter = this.getParameter(0) and
78-
exists(Expr errorCheck |
79-
isExplicitConditional(this.getFunction().getBodyStmt(0), errorCheck) and
80-
errorParameter.flowsTo(DataFlow::valueNode(errorCheck))
81-
)
78+
ifStmt = this.getFunction().getBodyStmt(0) and
79+
errorParameter.flowsToExpr(ifStmt.getCondition()) and
80+
not ifStmt.getThen().getBasicBlock().getASuccessor*() = this.getFunction().getBodyStmt(1).getBasicBlock()
8281
}
8382

8483
DataFlow::Node getErrorParam() { result = errorParameter }

javascript/ql/test/query-tests/Security/CWE-079/exception-xss.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,4 +174,13 @@ app.get('/user/:id', function(req, res) {
174174
new Promise(resolve => inner(foo, resolve)).catch((e) => {
175175
$('myId').html(e); // NOT OK
176176
});
177-
})();
177+
})();
178+
179+
app.get('/user/:id', function(req, res) {
180+
unknown(req.params.id, (error, res) => {
181+
if (error) {
182+
$('myId').html(error); // OK (falls through to the next statement)
183+
}
184+
$('myId').html(res); // OK (for now?)
185+
});
186+
});

0 commit comments

Comments
 (0)