Skip to content

Commit 4625217

Browse files
committed
Merge branch 'master' of github.com:Semmle/ql into js/more-fs-modules
2 parents adddebf + 88c74b2 commit 4625217

File tree

20 files changed

+608
-33
lines changed

20 files changed

+608
-33
lines changed

change-notes/1.24/analysis-javascript.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
| Regular expression always matches (`js/regex/always-matches`) | correctness, regular-expressions | Highlights regular expression checks that trivially succeed by matching an empty substring. Results are shown on LGTM by default. |
4545
| Missing await (`js/missing-await`) | correctness | Highlights expressions that operate directly on a promise object in a nonsensical way, instead of awaiting its result. Results are shown on LGTM by default. |
4646
| Polynomial regular expression used on uncontrolled data (`js/polynomial-redos`) | security, external/cwe/cwe-730, external/cwe/cwe-400 | Highlights expensive regular expressions that may be used on malicious input. Results are shown on LGTM by default. |
47-
| Prototype pollution in utility function (`js/prototype-pollution-utility`) | security, external/cwe/cwe-400, external/cwe/cwe-471 | Highlights recursive copying operations that are susceptible to prototype pollution. Results are shown on LGTM by default. |
47+
| Prototype pollution in utility function (`js/prototype-pollution-utility`) | security, external/cwe/cwe-400, external/cwe/cwe-471 | Highlights recursive assignment operations that are susceptible to prototype pollution. Results are shown on LGTM by default. |
4848
| Unsafe jQuery plugin (`js/unsafe-jquery-plugin`) | Highlights potential XSS vulnerabilities in unsafely designed jQuery plugins. Results are shown on LGTM by default. |
4949
| Unnecessary use of `cat` process (`js/unnecessary-use-of-cat`) | correctness, security, maintainability | Highlights command executions of `cat` where the fs API should be used instead. Results are shown on LGTM by default. |
5050

cpp/ql/src/semmle/code/cpp/ir/dataflow/DefaultTaintTracking.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ private predicate isChiForAllAliasedMemory(Instruction instr) {
275275
or
276276
isChiForAllAliasedMemory(instr.(ChiInstruction).getTotal())
277277
or
278-
isChiForAllAliasedMemory(instr.(PhiInstruction).getAnInput())
278+
isChiForAllAliasedMemory(instr.(PhiInstruction).getAnInputOperand().getAnyDef())
279279
}
280280

281281
private predicate modelTaintToReturnValue(Function f, int parameterIn) {

cpp/ql/src/semmle/code/cpp/ir/dataflow/internal/DataFlowDispatch.qll

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,12 @@ private module VirtualDispatch {
135135
exists(FunctionInstruction fi |
136136
this.flowsFrom(DataFlow::instructionNode(fi), _) and
137137
result = fi.getFunctionSymbol()
138+
) and
139+
(
140+
this.getNumberOfArguments() <= result.getEffectiveNumberOfParameters() and
141+
this.getNumberOfArguments() >= result.getEffectiveNumberOfParameters()
142+
or
143+
result.isVarargs()
138144
)
139145
}
140146
}

cpp/ql/src/semmle/code/cpp/ir/implementation/aliased_ssa/Instruction.qll

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1202,6 +1202,11 @@ class CallInstruction extends Instruction {
12021202
final Instruction getPositionalArgument(int index) {
12031203
result = getPositionalArgumentOperand(index).getDef()
12041204
}
1205+
1206+
/**
1207+
* Gets the number of arguments of the call, including the `this` pointer, if any.
1208+
*/
1209+
final int getNumberOfArguments() { result = count(this.getAnArgumentOperand()) }
12051210
}
12061211

12071212
/**

cpp/ql/src/semmle/code/cpp/ir/implementation/raw/Instruction.qll

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1202,6 +1202,11 @@ class CallInstruction extends Instruction {
12021202
final Instruction getPositionalArgument(int index) {
12031203
result = getPositionalArgumentOperand(index).getDef()
12041204
}
1205+
1206+
/**
1207+
* Gets the number of arguments of the call, including the `this` pointer, if any.
1208+
*/
1209+
final int getNumberOfArguments() { result = count(this.getAnArgumentOperand()) }
12051210
}
12061211

12071212
/**

cpp/ql/src/semmle/code/cpp/ir/implementation/unaliased_ssa/Instruction.qll

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1202,6 +1202,11 @@ class CallInstruction extends Instruction {
12021202
final Instruction getPositionalArgument(int index) {
12031203
result = getPositionalArgumentOperand(index).getDef()
12041204
}
1205+
1206+
/**
1207+
* Gets the number of arguments of the call, including the `this` pointer, if any.
1208+
*/
1209+
final int getNumberOfArguments() { result = count(this.getAnArgumentOperand()) }
12051210
}
12061211

12071212
/**

csharp/ql/src/semmle/code/csharp/ir/implementation/raw/Instruction.qll

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1202,6 +1202,11 @@ class CallInstruction extends Instruction {
12021202
final Instruction getPositionalArgument(int index) {
12031203
result = getPositionalArgumentOperand(index).getDef()
12041204
}
1205+
1206+
/**
1207+
* Gets the number of arguments of the call, including the `this` pointer, if any.
1208+
*/
1209+
final int getNumberOfArguments() { result = count(this.getAnArgumentOperand()) }
12051210
}
12061211

12071212
/**

csharp/ql/src/semmle/code/csharp/ir/implementation/unaliased_ssa/Instruction.qll

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1202,6 +1202,11 @@ class CallInstruction extends Instruction {
12021202
final Instruction getPositionalArgument(int index) {
12031203
result = getPositionalArgumentOperand(index).getDef()
12041204
}
1205+
1206+
/**
1207+
* Gets the number of arguments of the call, including the `this` pointer, if any.
1208+
*/
1209+
final int getNumberOfArguments() { result = count(this.getAnArgumentOperand()) }
12051210
}
12061211

12071212
/**

javascript/ql/src/Declarations/UnreachableMethodOverloads.ql

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,13 @@ predicate signaturesMatch(MethodSignature method, MethodSignature other) {
100100
method.getName() = other.getName() and
101101
// same number of parameters.
102102
method.getBody().getNumParameter() = other.getBody().getNumParameter() and
103+
// same this parameter (if exists)
104+
(
105+
not exists(method.getBody().getThisTypeAnnotation()) and
106+
not exists(other.getBody().getThisTypeAnnotation())
107+
or
108+
method.getBody().getThisTypeAnnotation().getType() = other.getBody().getThisTypeAnnotation().getType()
109+
) and
103110
// The types are compared in matchingCallSignature. This is sanity-check that the textual representation of the type-annotations are somewhat similar.
104111
forall(int i | i in [0 .. -1 + method.getBody().getNumParameter()] |
105112
getParameterTypeAnnotation(method, i) = getParameterTypeAnnotation(other, i)

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

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@
1313

1414
<p>
1515
One way to cause prototype pollution is through use of an unsafe <em>merge</em> or <em>extend</em> function
16-
to recursively copy properties from one object to another.
16+
to recursively copy properties from one object to another, or through the use of a <em>deep assignment</em>
17+
function to assign to an unverified chain of property names.
1718
Such a function has the potential to modify any object reachable from the destination object, and
1819
the built-in <code>Object.prototype</code> is usually reachable through the special properties
1920
<code>__proto__</code> and <code>constructor.prototype</code>.
@@ -23,13 +24,13 @@
2324
<recommendation>
2425
<p>
2526
The most effective place to guard against this is in the function that performs
26-
the recursive copy.
27+
the recursive copy or deep assignment.
2728
</p>
2829

2930
<p>
30-
Only merge a property recursively when it is an own property of the <em>destination</em> object.
31+
Only merge or assign a property recursively when it is an own property of the <em>destination</em> object.
3132
Alternatively, blacklist the property names <code>__proto__</code> and <code>constructor</code>
32-
from being merged.
33+
from being merged or assigned to.
3334
</p>
3435
</recommendation>
3536

0 commit comments

Comments
 (0)