Skip to content

Commit d76859b

Browse files
committed
JS: Address review comments
1 parent 2c05ee8 commit d76859b

File tree

3 files changed

+27
-3
lines changed

3 files changed

+27
-3
lines changed

javascript/ql/src/Security/CWE-400/PrototypePollutionUtility.qhelp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@
4141
<sample src="examples/PrototypePollutionUtility.js"/>
4242

4343
<p>
44-
However, if <code>src</code> is the object <code>{"__proto__": {"xxx": true}}</code>,
45-
it will inject the property <code>xxx: true</code> in in <code>Object.prototype</code>.
44+
However, if <code>src</code> is the object <code>{"__proto__": {"isAdmin": true}}</code>,
45+
it will inject the property <code>isAdmin: true</code> in in <code>Object.prototype</code>.
4646
</p>
4747

4848
<p>

javascript/ql/src/Security/CWE-400/PrototypePollutionUtility.ql

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,13 @@ class UnsafePropLabel extends FlowLabel {
226226
*
227227
* Note that in the above example, the flow from `key` to the base of the write (`dst`)
228228
* requires stepping through the recursive call.
229-
* Such a path would be absent for a shallow copying operation.
229+
* Such a path would be absent for a shallow copying operation, where the `dst` object
230+
* isn't derived from a property of the source object.
231+
*
232+
* This configuration can't enforce that all three paths must end at the same
233+
* dynamic property write, so we treat the paths independently here and check
234+
* for coinciding paths afterwards. This means this configuration can't be used as
235+
* a standalone configuration like in most path queries.
230236
*/
231237
class PropNameTracking extends DataFlow::Configuration {
232238
PropNameTracking() { this = "PropNameTracking" }

javascript/ql/src/semmle/javascript/GlobalAccessPaths.qll

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,24 @@ module GlobalAccessPath {
3535
}
3636
}
3737

38+
/**
39+
* Provides predicates for associating access paths with data flow nodes.
40+
*
41+
* For example, `AccessPath.getAReferenceTo(x)` can be used to obtain the global access path
42+
* that `x` refers to, as in the following sample:
43+
* ```
44+
* function f() {
45+
* let v = foo.bar; // reference to 'foo.bar'
46+
* v.baz; // reference to 'foo.bar.baz'
47+
* }
48+
*
49+
* (function(ns) {
50+
* ns.x; // reference to 'NS.x'
51+
* })(NS = NS || {});
52+
* ```
53+
*
54+
* A pseudo-property named `[number]` is sometimes used to represent array indices within an access path.
55+
*/
3856
module AccessPath {
3957
/**
4058
* A source node that can be the root of an access path.

0 commit comments

Comments
 (0)