Skip to content

Commit b321151

Browse files
committed
JS: Restrict ExtendCall flow in proto pollution query
1 parent efb582b commit b321151

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

javascript/ql/lib/semmle/javascript/security/dataflow/PrototypePollutingAssignmentQuery.qll

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,18 @@ class Configuration extends TaintTracking::Configuration {
5757
node = NodeJSLib::Path::moduleMember(["join", "normalize", "relative", "resolve"]).getACall()
5858
}
5959

60+
override predicate isSanitizerEdge(
61+
DataFlow::Node pred, DataFlow::Node succ, DataFlow::FlowLabel lbl
62+
) {
63+
// Suppress the value-preserving step src -> dst in `extend(dst, src)`. This is modeled as a value-preserving
64+
// step because it preserves all properties, but the destination is not actually Object.prototype.
65+
exists(ExtendCall call |
66+
pred = call.getASourceOperand() and
67+
succ = call.getDestinationOperand().getALocalSource() and
68+
lbl instanceof ObjectPrototype
69+
)
70+
}
71+
6072
override predicate isAdditionalFlowStep(
6173
DataFlow::Node pred, DataFlow::Node succ, DataFlow::FlowLabel inlbl, DataFlow::FlowLabel outlbl
6274
) {

0 commit comments

Comments
 (0)