Skip to content

Commit 18eb60b

Browse files
authored
Merge pull request #687 from adityasharad/merge/master-next-131218
Merge master into next.
2 parents 1158708 + f71e5ac commit 18eb60b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+515
-133
lines changed

change-notes/1.20/analysis-javascript.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,11 @@
44

55
* Support for popular libraries has been improved. Consequently, queries may produce more results on code bases that use the following features:
66
- client-side code, for example [React](https://reactjs.org/)
7+
- cookies and webstorage, for example [js-cookie](https://github.com/js-cookie/js-cookie)
78
- server-side code, for example [hapi](https://hapijs.com/)
9+
* File classification has been improved to recognize additional generated files, for example files from [HTML Tidy](html-tidy.org).
10+
11+
* The taint tracking library now recognizes flow through persistent storage, this may give more results for the security queries.
812

913
## New queries
1014

@@ -20,6 +24,7 @@
2024
| **Query** | **Expected impact** | **Change** |
2125
|--------------------------------------------|------------------------------|------------------------------------------------------------------------------|
2226
| Client-side cross-site scripting | More results | This rule now recognizes WinJS functions that are vulnerable to HTML injection. |
27+
| Insecure randomness | More results | This rule now flags insecure uses of `crypto.pseudoRandomBytes`. |
2328
| Unused parameter | Fewer false-positive results | This rule no longer flags parameters with leading underscore. |
2429
| Unused variable, import, function or class | Fewer false-positive results | This rule now flags fewer variables that are implictly used by JSX elements, and no longer flags variables with leading underscore. |
2530

cpp/ql/src/Metrics/queries.xml

Lines changed: 0 additions & 1 deletion
This file was deleted.

cpp/ql/src/semmle/code/cpp/commons/Environment.qll

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,5 @@ private predicate readsEnvironment(Expr read, string sourceDescription) {
3434
read = call and
3535
call.getTarget().hasGlobalName(name) and
3636
(name = "getenv" or name = "secure_getenv" or name = "_wgetenv") and
37-
sourceDescription = name) or
38-
exists(MessageExpr getObjectKey, MessageExpr getEnviron |
39-
read = getObjectKey and
40-
getObjectKey.getTarget().getQualifiedName().matches("NSDictionary%::-objectForKey:") and
41-
getObjectKey.getQualifier() = getEnviron and
42-
getEnviron.getTarget().getQualifiedName().matches("NSProcessInfo%:-environment") and
43-
sourceDescription = "NSProcessInfo")
37+
sourceDescription = name)
4438
}

cpp/ql/src/semmle/code/cpp/security/CommandExecution.qll

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -203,18 +203,5 @@ predicate shellCommand(Expr command, string callChain) {
203203
and arrayInitializer.getChild(idx) = command
204204
and shellCommandPreface(commandInterpreter.getValue(), flag.getValue())
205205
and idx > 1)
206-
207-
// Creation of NSTask
208-
or exists(
209-
MessageExpr launchedTaskCall, TextLiteral commandInterpreter,
210-
Expr arrayLiteral, TextLiteral flag
211-
|
212-
launchedTaskCall.getStaticTarget().getQualifiedName().matches("NSTask%::+launchedTaskWithLaunchPath:arguments:")
213-
and commandInterpreter = launchedTaskCall.getArgument(0)
214-
and arrayLiteral = launchedTaskCall.getArgument(1)
215-
and arrayElement(arrayLiteral, 0, flag)
216-
and arrayElement(arrayLiteral, 1, command)
217-
and shellCommandPreface(commandInterpreter.getValue(), flag.getValue())
218-
and callChain = "NSTask")
219206
}
220207

cpp/ql/src/semmle/code/cpp/security/SensitiveExprs.qll

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -35,25 +35,3 @@ class SensitiveCall extends SensitiveExpr {
3535
)
3636
}
3737
}
38-
39-
class SensitivePropAccess extends SensitiveExpr {
40-
SensitivePropAccess() {
41-
exists (PropertyAccess acc, string name |
42-
acc = this and
43-
name = acc.getProperty().getName().toLowerCase() and
44-
name.matches(suspicious()) and
45-
not name.matches(nonSuspicious()))
46-
}
47-
}
48-
49-
/**
50-
* A read from the value of a text widget.
51-
*/
52-
class SensitiveTextRead extends SensitiveExpr {
53-
SensitiveTextRead() {
54-
exists (PropertyAccess facc |
55-
facc = this and
56-
facc.getReceiver() instanceof SensitiveExpr and
57-
facc.getProperty().getName() = "text")
58-
}
59-
}

cpp/ql/src/semmle/code/cpp/security/TaintTracking.qll

Lines changed: 0 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -238,21 +238,12 @@ predicate insideFunctionValueMoveTo(Element src, Element dest)
238238
returnArgument(c.getTarget(), sourceArg)
239239
and src = c.getArgument(sourceArg)
240240
and dest = c)
241-
or exists (MessageExpr send |
242-
methodReturningAnyArgument(send.getStaticTarget())
243-
and not send instanceof FormattingFunctionCall
244-
and src = send.getAnArgument()
245-
and dest = send)
246241
or exists(FormattingFunctionCall formattingSend, int arg, FormatLiteral format, string argFormat |
247242
dest = formattingSend
248243
and formattingSend.getArgument(arg) = src
249244
and format = formattingSend.getFormat()
250245
and format.getConversionChar(arg - formattingSend.getTarget().getNumberOfParameters()) = argFormat
251246
and (argFormat = "s" or argFormat = "S" or argFormat = "@"))
252-
or exists (ExprMessageExpr send |
253-
methodReturningReceiver(send.getStaticTarget())
254-
and src = send.getReceiver()
255-
and dest = send)
256247
// Expressions computed from tainted data are also tainted
257248
or (exists (FunctionCall call | dest = call and isPureFunction(call.getTarget().getName()) |
258249
call.getAnArgument() = src
@@ -457,60 +448,6 @@ private predicate returnArgument(Function f, int sourceArg)
457448
or (f.hasGlobalName("gethostbyaddr") and sourceArg = 0)
458449
}
459450

460-
/** A method where if any argument is tainted, the return value should be, too */
461-
private predicate methodReturningAnyArgument(MemberFunction method) {
462-
method.getQualifiedName().matches("NS%Array%::+array%") or
463-
method.getQualifiedName().matches("NS%Array%::-arrayBy%") or
464-
method.getQualifiedName().matches("NS%Array%::-componentsJoinedByString:") or
465-
method.getQualifiedName().matches("NS%Array%::-init%") or
466-
method.getQualifiedName().matches("NS%Data%::+dataWith%") or
467-
method.getQualifiedName().matches("NS%Data%::-initWith%") or
468-
method.getQualifiedName().matches("NS%String%::+pathWithComponents:") or
469-
method.getQualifiedName().matches("NS%String%::+stringWith%") or
470-
method.getQualifiedName().matches("NS%String%::-initWithCString:") or
471-
method.getQualifiedName().matches("NS%String%::-initWithCString:length:") or
472-
method.getQualifiedName().matches("NS%String%::-initWithCStringNoCopy:length:") or
473-
method.getQualifiedName().matches("NS%String%::-initWithCharacters:length:") or
474-
method.getQualifiedName().matches("NS%String%::-initWithCharactersNoCopy:length:freeWhenDone:") or
475-
method.getQualifiedName().matches("NS%String%::-initWithFormat:") or
476-
method.getQualifiedName().matches("NS%String%::-initWithFormat:arguments:") or
477-
method.getQualifiedName().matches("NS%String%::-initWithString:") or
478-
method.getQualifiedName().matches("NS%String%::-initWithUTF8String:") or
479-
method.getQualifiedName().matches("NS%String%::-stringByAppendingFormat:") or
480-
method.getQualifiedName().matches("NS%String%::-stringByAppendingString:") or
481-
method.getQualifiedName().matches("NS%String%::-stringByPaddingToLength:withString:startingAtIndex:") or
482-
method.getQualifiedName().matches("NS%String%::-stringByReplacing%") or
483-
method.getQualifiedName().matches("NS%String%::-stringsByAppendingPaths:")
484-
}
485-
486-
/** A method where if the receiver is tainted, the return value should be, too */
487-
private predicate methodReturningReceiver(MemberFunction method) {
488-
method.getQualifiedName().matches("NS%Array%::-arrayBy%") or
489-
method.getQualifiedName().matches("NS%Array%::-componentsJoinedByString:") or
490-
method.getQualifiedName().matches("NS%Array%::-firstObject") or
491-
method.getQualifiedName().matches("NS%Array%::-lastObject") or
492-
method.getQualifiedName().matches("NS%Array%::-objectAt%") or
493-
method.getQualifiedName().matches("NS%Array%::-pathsMatchingExtensions:") or
494-
method.getQualifiedName().matches("NS%Array%::-sortedArray%") or
495-
method.getQualifiedName().matches("NS%Array%::-subarrayWithRange:") or
496-
method.getQualifiedName().matches("NS%Data%::-bytes") or
497-
method.getQualifiedName().matches("NS%Data%::-subdataWithRange:") or
498-
method.getQualifiedName().matches("NS%String%::-capitalizedString%") or
499-
method.getQualifiedName().matches("NS%String%::-componentsSeparatedByCharactersInSet:") or
500-
method.getQualifiedName().matches("NS%String%::-componentsSeparatedByString:") or
501-
method.getQualifiedName().matches("NS%String%::-cStringUsingEncoding:") or
502-
method.getQualifiedName().matches("NS%String%::-dataUsingEncoding:%") or
503-
method.getQualifiedName().matches("NS%String%::-lowercaseString%") or
504-
method.getQualifiedName().matches("NS%String%::-pathComponents") or
505-
method.getQualifiedName().matches("NS%String%::-stringBy%") or
506-
method.getQualifiedName().matches("NS%String%::-stringsByAppendingPaths:") or
507-
method.getQualifiedName().matches("NS%String%::-substringFromIndex:") or
508-
method.getQualifiedName().matches("NS%String%::-substringToIndex:") or
509-
method.getQualifiedName().matches("NS%String%::-substringWithRange:") or
510-
method.getQualifiedName().matches("NS%String%::-uppercaseString%") or
511-
method.getQualifiedName().matches("NS%String%::-UTF8String")
512-
}
513-
514451
/**
515452
* Resolve potential target function(s) for `call`.
516453
*

csharp/ql/src/Language Abuse/UselessUpcast.ql

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -118,8 +118,9 @@ class ExplicitUpcast extends ExplicitCast {
118118
}
119119

120120
pragma [nomagic]
121-
private predicate isDisambiguatingStaticCall0(StaticCall c, StaticCallable target, ValueOrRefType t) {
121+
private predicate isDisambiguatingStaticCall0(StaticCall c, StaticCallable target, string name, ValueOrRefType t) {
122122
this.isArgument(c, target) and
123+
name = target.getName() and
123124
(
124125
t = c.(QualifiableExpr).getQualifier().getType()
125126
or
@@ -131,9 +132,9 @@ class ExplicitUpcast extends ExplicitCast {
131132
/** Holds if this upcast may be used to disambiguate the target of a static call. */
132133
pragma [nomagic]
133134
private predicate isDisambiguatingStaticCall(StaticCallable other, int args) {
134-
exists(StaticCall c, StaticCallable target, ValueOrRefType t |
135-
this.isDisambiguatingStaticCall0(c, target, t) |
136-
hasStaticCallable(t, other, target.getName()) and
135+
exists(StaticCall c, StaticCallable target, ValueOrRefType t, string name |
136+
this.isDisambiguatingStaticCall0(c, target, name, t) |
137+
hasStaticCallable(t, other, name) and
137138
args = c.getNumberOfArguments() and
138139
other != target
139140
)

javascript/ql/src/Security/CWE-116/IncompleteSanitization.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ string metachar() {
2525
string getAMatchedString(Expr e) {
2626
result = getAMatchedConstant(e.(RegExpLiteral).getRoot()).getValue()
2727
or
28-
result = e.(StringLiteral).getValue()
28+
result = e.getStringValue()
2929
}
3030

3131
/** Gets a constant matched by `t`. */

javascript/ql/src/javascript.qll

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ import semmle.javascript.frameworks.Azure
6060
import semmle.javascript.frameworks.Babel
6161
import semmle.javascript.frameworks.ComposedFunctions
6262
import semmle.javascript.frameworks.ClientRequests
63+
import semmle.javascript.frameworks.CookieLibraries
6364
import semmle.javascript.frameworks.Credentials
6465
import semmle.javascript.frameworks.CryptoLibraries
6566
import semmle.javascript.frameworks.DigitalOcean

javascript/ql/src/semmle/javascript/Concepts.qll

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,3 +65,27 @@ abstract class DatabaseAccess extends DataFlow::Node {
6565
/** Gets an argument to this database access that is interpreted as a query. */
6666
abstract DataFlow::Node getAQueryArgument();
6767
}
68+
69+
/**
70+
* A data flow node that reads persistent data.
71+
*/
72+
abstract class PersistentReadAccess extends DataFlow::Node {
73+
74+
/**
75+
* Gets a corresponding persistent write, if any.
76+
*/
77+
abstract PersistentWriteAccess getAWrite();
78+
79+
}
80+
81+
/**
82+
* A data flow node that writes persistent data.
83+
*/
84+
abstract class PersistentWriteAccess extends DataFlow::Node {
85+
86+
/**
87+
* Gets the data flow node corresponding to the written value.
88+
*/
89+
abstract DataFlow::Node getValue();
90+
91+
}

0 commit comments

Comments
 (0)