Skip to content

Commit fcd13dc

Browse files
committed
Merge remote-tracking branch 'upstream/master' into ASPNetRequestValidationMode
# Conflicts: # change-notes/1.24/analysis-csharp.md
2 parents 8026925 + ceb9fff commit fcd13dc

File tree

45 files changed

+760
-137
lines changed

Some content is hidden

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

45 files changed

+760
-137
lines changed

change-notes/1.24/analysis-csharp.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,7 @@ The following changes in version 1.24 affect C# analysis in all applications.
1919

2020
## Changes to libraries
2121

22+
* The taint tracking library now tracks flow through (implicit or explicit) conversion operator calls.
23+
2224
## Changes to autobuilder
25+

change-notes/1.24/analysis-javascript.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@
1111

1212
## New queries
1313

14-
| **Query** | **Tags** | **Purpose** |
15-
|---------------------------------------------------------------------------|-------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
16-
14+
| **Query** | **Tags** | **Purpose** |
15+
|---------------------------------------------------------------------------------|-------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
16+
| Cross-site scripting through exception (`js/xss-through-exception`) | security, external/cwe/cwe-079, external/cwe/cwe-116 | Highlights potential XSS vulnerabilities where an exception is written to the DOM. Results are not shown on LGTM by default. |
1717

1818
## Changes to existing queries
1919

@@ -25,3 +25,4 @@
2525

2626
## Changes to libraries
2727

28+
* The predicates `RegExpTerm.getSuccessor` and `RegExpTerm.getPredecessor` have been changed to reflect textual, not operational, matching order. This only makes a difference in lookbehind assertions, which are operationally matched backwards. Previously, `getSuccessor` would mimick this, so in an assertion `(?<=ab)` the term `b` would be considered the predecessor, not the successor, of `a`. Textually, however, `a` is still matched before `b`, and this is the order we now follow.

cpp/ql/src/Likely Bugs/Underspecified Functions/MistypedFunctionArguments.ql

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -84,18 +84,18 @@ predicate hasZeroParamDecl(Function f) {
8484
}
8585

8686
// True if this file (or header) was compiled as a C file
87-
predicate isCompiledAsC(Function f) {
88-
exists(File file | file.compiledAsC() |
89-
file = f.getFile() or file.getAnIncludedFile+() = f.getFile()
90-
)
87+
predicate isCompiledAsC(File f) {
88+
f.compiledAsC()
89+
or
90+
exists(File src | isCompiledAsC(src) | src.getAnIncludedFile() = f)
9191
}
9292

9393
from FunctionCall fc, Function f, Parameter p
9494
where
9595
f = fc.getTarget() and
9696
p = f.getAParameter() and
9797
hasZeroParamDecl(f) and
98-
isCompiledAsC(f) and
98+
isCompiledAsC(f.getFile()) and
9999
not f.isVarargs() and
100100
not f instanceof BuiltInFunction and
101101
p.getIndex() < fc.getNumberOfArguments() and

cpp/ql/src/Likely Bugs/Underspecified Functions/TooFewArguments.ql

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@ predicate hasZeroParamDecl(Function f) {
2424
}
2525

2626
// True if this file (or header) was compiled as a C file
27-
predicate isCompiledAsC(Function f) {
28-
exists(File file | file.compiledAsC() |
29-
file = f.getFile() or file.getAnIncludedFile+() = f.getFile()
30-
)
27+
predicate isCompiledAsC(File f) {
28+
f.compiledAsC()
29+
or
30+
exists(File src | isCompiledAsC(src) | src.getAnIncludedFile() = f)
3131
}
3232

3333
from FunctionCall fc, Function f
@@ -36,7 +36,7 @@ where
3636
not f.isVarargs() and
3737
not f instanceof BuiltInFunction and
3838
hasZeroParamDecl(f) and
39-
isCompiledAsC(f) and
39+
isCompiledAsC(f.getFile()) and
4040
// There is an explicit declaration of the function whose parameter count is larger
4141
// than the number of call arguments
4242
exists(FunctionDeclarationEntry fde | fde = f.getADeclarationEntry() |

cpp/ql/src/Likely Bugs/Underspecified Functions/TooManyArguments.ql

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,18 +25,18 @@ predicate hasZeroParamDecl(Function f) {
2525
}
2626

2727
// True if this file (or header) was compiled as a C file
28-
predicate isCompiledAsC(Function f) {
29-
exists(File file | file.compiledAsC() |
30-
file = f.getFile() or file.getAnIncludedFile+() = f.getFile()
31-
)
28+
predicate isCompiledAsC(File f) {
29+
f.compiledAsC()
30+
or
31+
exists(File src | isCompiledAsC(src) | src.getAnIncludedFile() = f)
3232
}
3333

3434
from FunctionCall fc, Function f
3535
where
3636
f = fc.getTarget() and
3737
not f.isVarargs() and
3838
hasZeroParamDecl(f) and
39-
isCompiledAsC(f) and
39+
isCompiledAsC(f.getFile()) and
4040
exists(f.getBlock()) and
4141
// There must not exist a declaration with the number of parameters
4242
// at least as large as the number of call arguments

csharp/ql/src/semmle/code/csharp/dataflow/internal/TaintTrackingPrivate.qll

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,12 @@ private class LocalTaintExprStepConfiguration extends ControlFlowReachabilityCon
113113
scope = e2 and
114114
isSuccessor = true
115115
)
116+
or
117+
e2 = any(OperatorCall oc |
118+
oc.getTarget().(ConversionOperator).fromLibrary() and
119+
e1 = oc.getAnArgument() and
120+
isSuccessor = true
121+
)
116122
)
117123
}
118124

csharp/ql/test/library-tests/dataflow/local/DataFlowStep.expected

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -586,6 +586,9 @@
586586
| LocalDataFlow.cs:480:67:480:68 | os | LocalDataFlow.cs:486:32:486:33 | access to parameter os |
587587
| LocalDataFlow.cs:483:21:483:21 | access to parameter x | LocalDataFlow.cs:483:16:483:21 | ... = ... |
588588
| LocalDataFlow.cs:486:32:486:33 | access to parameter os | LocalDataFlow.cs:486:26:486:33 | ... = ... |
589+
| LocalDataFlow.cs:491:41:491:44 | args | LocalDataFlow.cs:493:29:493:32 | access to parameter args |
590+
| LocalDataFlow.cs:493:29:493:32 | [post] access to parameter args | LocalDataFlow.cs:494:27:494:30 | access to parameter args |
591+
| LocalDataFlow.cs:493:29:493:32 | access to parameter args | LocalDataFlow.cs:494:27:494:30 | access to parameter args |
589592
| SSA.cs:5:17:5:17 | SSA entry def(this.S) | SSA.cs:67:9:67:14 | access to field S |
590593
| SSA.cs:5:17:5:17 | this | SSA.cs:67:9:67:12 | this access |
591594
| SSA.cs:5:26:5:32 | tainted | SSA.cs:8:24:8:30 | access to parameter tainted |

csharp/ql/test/library-tests/dataflow/local/LocalDataFlow.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -485,4 +485,12 @@ public void AssignmentFlow(IDisposable x, IEnumerable<object> os)
485485
IEnumerable<object> os2;
486486
foreach(var o in os2 = os) { }
487487
}
488+
489+
public static implicit operator LocalDataFlow(string[] args) => null;
490+
491+
public void ConversionFlow(string[] args)
492+
{
493+
Span<object> span = args; // flow (library operator)
494+
LocalDataFlow x = args; // no flow (source code operator)
495+
}
488496
}

csharp/ql/test/library-tests/dataflow/local/TaintTrackingStep.expected

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -736,6 +736,11 @@
736736
| LocalDataFlow.cs:480:67:480:68 | os | LocalDataFlow.cs:486:32:486:33 | access to parameter os |
737737
| LocalDataFlow.cs:483:21:483:21 | access to parameter x | LocalDataFlow.cs:483:16:483:21 | ... = ... |
738738
| LocalDataFlow.cs:486:32:486:33 | access to parameter os | LocalDataFlow.cs:486:26:486:33 | ... = ... |
739+
| LocalDataFlow.cs:491:41:491:44 | args | LocalDataFlow.cs:491:41:491:44 | args |
740+
| LocalDataFlow.cs:491:41:491:44 | args | LocalDataFlow.cs:493:29:493:32 | access to parameter args |
741+
| LocalDataFlow.cs:493:29:493:32 | [post] access to parameter args | LocalDataFlow.cs:494:27:494:30 | access to parameter args |
742+
| LocalDataFlow.cs:493:29:493:32 | access to parameter args | LocalDataFlow.cs:493:29:493:32 | call to operator implicit conversion |
743+
| LocalDataFlow.cs:493:29:493:32 | access to parameter args | LocalDataFlow.cs:494:27:494:30 | access to parameter args |
739744
| SSA.cs:5:17:5:17 | SSA entry def(this.S) | SSA.cs:67:9:67:14 | access to field S |
740745
| SSA.cs:5:17:5:17 | this | SSA.cs:67:9:67:12 | this access |
741746
| SSA.cs:5:26:5:32 | tainted | SSA.cs:5:26:5:32 | tainted |

csharp/ql/test/library-tests/frameworks/EntityFramework/EntityFrameworkCore.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ void TestDataFlow()
5050
Sink(taintSource); // Tainted
5151
Sink(new RawSqlString(taintSource)); // Tainted
5252
Sink((RawSqlString)taintSource); // Tainted
53-
Sink((RawSqlString)(FormattableString)$"{taintSource}"); // Not tainted
53+
Sink((RawSqlString)(FormattableString)$"{taintSource}"); // Tainted, but not reported because conversion operator is in a stub .cs file
5454

5555
// Tainted via database, even though technically there were no reads or writes to the database in this particular case.
5656
var p1 = new Person { Name = taintSource };

0 commit comments

Comments
 (0)