File tree 5 files changed +39
-2
lines changed
semmle/code/csharp/security
test/query-tests/Security Features/CWE-117
5 files changed +39
-2
lines changed Original file line number Diff line number Diff line change
1
+ ---
2
+ category : minorAnalysis
3
+ ---
4
+ * ` DateTime ` expressions are now considered simple type sanitizers. This affects a wide range of security queries.
Original file line number Diff line number Diff line change @@ -54,7 +54,12 @@ class UrlSanitizedExpr extends Expr {
54
54
* An expression node with a simple type.
55
55
*/
56
56
class SimpleTypeSanitizedExpr extends DataFlow:: ExprNode {
57
- SimpleTypeSanitizedExpr ( ) { this .getType ( ) instanceof SimpleType }
57
+ SimpleTypeSanitizedExpr ( ) {
58
+ exists ( Type t | t = this .getType ( ) |
59
+ t instanceof SimpleType or
60
+ t instanceof SystemDateTimeStruct
61
+ )
62
+ }
58
63
}
59
64
60
65
/**
Original file line number Diff line number Diff line change 4
4
| LogForging.cs:17:27:17:49 | access to property QueryString : NameValueCollection | LogForging.cs:26:50:26:72 | ... + ... |
5
5
| LogForging.cs:17:27:17:61 | access to indexer : String | LogForging.cs:20:21:20:43 | ... + ... |
6
6
| LogForging.cs:17:27:17:61 | access to indexer : String | LogForging.cs:26:50:26:72 | ... + ... |
7
+ | LogForgingAsp.cs:8:32:8:39 | username : String | LogForgingAsp.cs:12:21:12:43 | ... + ... |
7
8
nodes
8
9
| LogForging.cs:17:27:17:49 | access to property QueryString : NameValueCollection | semmle.label | access to property QueryString : NameValueCollection |
9
10
| LogForging.cs:17:27:17:61 | access to indexer : String | semmle.label | access to indexer : String |
10
11
| LogForging.cs:20:21:20:43 | ... + ... | semmle.label | ... + ... |
11
12
| LogForging.cs:26:50:26:72 | ... + ... | semmle.label | ... + ... |
13
+ | LogForgingAsp.cs:8:32:8:39 | username : String | semmle.label | username : String |
14
+ | LogForgingAsp.cs:12:21:12:43 | ... + ... | semmle.label | ... + ... |
12
15
subpaths
13
16
#select
14
17
| LogForging.cs:20:21:20:43 | ... + ... | LogForging.cs:17:27:17:49 | access to property QueryString : NameValueCollection | LogForging.cs:20:21:20:43 | ... + ... | $@ flows to log entry. | LogForging.cs:17:27:17:49 | access to property QueryString | User-provided value |
15
18
| LogForging.cs:26:50:26:72 | ... + ... | LogForging.cs:17:27:17:49 | access to property QueryString : NameValueCollection | LogForging.cs:26:50:26:72 | ... + ... | $@ flows to log entry. | LogForging.cs:17:27:17:49 | access to property QueryString | User-provided value |
19
+ | LogForgingAsp.cs:12:21:12:43 | ... + ... | LogForgingAsp.cs:8:32:8:39 | username : String | LogForgingAsp.cs:12:21:12:43 | ... + ... | $@ flows to log entry. | LogForgingAsp.cs:8:32:8:39 | username | User-provided value |
Original file line number Diff line number Diff line change
1
+ using System ;
2
+ using Microsoft . AspNetCore . Http ;
3
+ using Microsoft . AspNetCore . Http . Headers ;
4
+ using Microsoft . AspNetCore . Mvc ;
5
+
6
+ public class AspController : ControllerBase
7
+ {
8
+ public void Action1 ( string username )
9
+ {
10
+ var logger = new ILogger ( ) ;
11
+ // BAD: Logged as-is
12
+ logger . Warn ( username + " logged in" ) ;
13
+ }
14
+
15
+ public void Action1 ( DateTime date )
16
+ {
17
+ var logger = new ILogger ( ) ;
18
+ // GOOD: DateTime is a sanitizer.
19
+ logger . Warn ( $ "Warning about the date: { date : yyyy-MM-dd} ") ;
20
+ }
21
+ }
Original file line number Diff line number Diff line change 1
- semmle-extractor-options: ${testdir}/../../../resources/stubs/System.Web.cs /r:System.Collections.Specialized.dll /r:System.Runtime.Extensions.dll /r:System.Diagnostics.TraceSource.dll
1
+ semmle-extractor-options: /nostdlib /noconfig
2
+ semmle-extractor-options: --load-sources-from-project:${testdir}/../../../resources/stubs/_frameworks/Microsoft.NETCore.App/Microsoft.NETCore.App.csproj
3
+ semmle-extractor-options: --load-sources-from-project:../../../resources/stubs/_frameworks/Microsoft.AspNetCore.App/Microsoft.AspNetCore.App.csproj
4
+ semmle-extractor-options: ${testdir}/../../../resources/stubs/System.Web.cs
You can’t perform that action at this time.
0 commit comments