Skip to content

Commit 8f17db6

Browse files
committed
changes based on review feedback
1 parent 7c93145 commit 8f17db6

2 files changed

Lines changed: 20 additions & 6 deletions

File tree

javascript/ql/src/semmle/javascript/StandardLibrary.qll

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,8 +211,13 @@ private class PromiseFlowStep extends DataFlow::AdditionalFlowStep {
211211

212212
/**
213213
* A data flow edge from the exceptional return of the promise executor to the promise catch handler.
214+
* This only adds an edge from the exceptional return of the promise Executor and to a `.catch()` handler.
215+
* Missing are (at least):
216+
* Exceptional flow from promise executor (and handlers) to exceptional return of an `await` expression.
217+
* Flow from calls to `reject` to exceptional return of an `await` expression.
218+
* Restricting flow to only the first catch handler after an exception.
214219
*/
215-
class PromiseExceptionalStep extends DataFlow::AdditionalFlowStep {
220+
private class PromiseExceptionalStep extends DataFlow::AdditionalFlowStep {
216221
PromiseDefinition promise;
217222
PromiseExceptionalStep() {
218223
promise = this

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

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -78,10 +78,17 @@ module ExceptionXss {
7878
)
7979
}
8080

81+
/**
82+
* Get the parameter in the callback that contains an error.
83+
* In the current implementation this is always the first parameter.
84+
*/
8185
DataFlow::Node getErrorParam() { result = errorParameter }
8286
}
8387

84-
// `someFunction(.. <pred> .., (<result>, value) => {...}).
88+
/**
89+
* Gets the error parameter for a callback that is supplied to the same call as `pred` is an argument to.
90+
* E.g: `outerCall(foo, <pred>, bar, (<result>, val) => { ... })`.
91+
*/
8592
DataFlow::Node getCallbackErrorParam(DataFlow::Node pred) {
8693
exists(DataFlow::CallNode call, Callback callback |
8794
pred = call.getAnArgument() and
@@ -92,10 +99,12 @@ module ExceptionXss {
9299
}
93100

94101
/**
95-
* Gets the DataFlow::Node where an exception would flow to if `pred` is used in some context
96-
* where an exception could potentially be thrown.
102+
* Gets the data-flow node where exceptions thrown by this expression will
103+
* propagate if this expression causes an exception to be thrown.
104+
* This predicate adds, on top of `Expr::getExceptionTarget`, exceptions
105+
* propagated by callbacks.
97106
*/
98-
DataFlow::Node getWhereExceptionWouldFlow(DataFlow::Node pred) {
107+
private DataFlow::Node getExceptionTarget(DataFlow::Node pred) {
99108
result = pred.asExpr().getExceptionTarget()
100109
or
101110
result = getCallbackErrorParam(pred)
@@ -126,7 +135,7 @@ module ExceptionXss {
126135
inlbl instanceof NotYetThrown and
127136
(outlbl.isTaint() or outlbl instanceof NotYetThrown) and
128137
canThrowSensitiveInformation(pred) and
129-
succ = getWhereExceptionWouldFlow(pred)
138+
succ = getExceptionTarget(pred)
130139
or
131140
// All the usual taint-flow steps apply on data-flow before it has been thrown in an exception.
132141
this.isAdditionalFlowStep(pred, succ) and

0 commit comments

Comments
 (0)