Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 2b120de

Browse files
authored
Merge pull request #2211 from hvitved/csharp/unsafe-deserialization
Approved by jf205
2 parents 3a7f9a5 + 508b09f commit 2b120de

11 files changed

Lines changed: 32 additions & 94 deletions

File tree

change-notes/1.23/analysis-csharp.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@ The following changes in version 1.23 affect C# analysis in all applications.
99
| **Query** | **Tags** | **Purpose** |
1010
|-----------------------------|-----------|--------------------------------------------------------------------|
1111
| Deserialized delegate (`cs/deserialized-delegate`) | security, external/cwe/cwe-502 | Finds unsafe deserialization of delegate types. |
12+
| Deserialization of untrusted data (`cs/unsafe-deserialization-untrusted-input`) | security, external/cwe/cwe-502 | Finds flow of untrusted input to calls to unsafe deserializers. |
1213
| Unsafe year argument for 'DateTime' constructor (`cs/unsafe-year-construction`) | reliability, date-time | Finds incorrect manipulation of `DateTime` values, which could lead to invalid dates. |
14+
| Unsafe deserializer (`cs/unsafe-deserialization`) | security, external/cwe/cwe-502 | Finds calls to unsafe deserializers. |
1315
| Mishandling the Japanese era start date (`cs/mishandling-japanese-era`) | reliability, date-time | Finds hard-coded Japanese era start dates that could be invalid. |
1416

1517
## Changes to existing queries

csharp/ql/src/Security Features/CWE-502/UnsafeDeserialization.qhelp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<overview>
66

77
<p>Deserializing an object from untrusted input may result in security problems, such
8-
as denial-of-service or remote code execution.</p>
8+
as denial of service or remote code execution.</p>
99

1010
</overview>
1111
<recommendation>

csharp/ql/src/Security Features/CWE-502/UnsafeDeserialization.ql

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,13 @@
55
* @kind problem
66
* @id cs/unsafe-deserialization
77
* @problem.severity warning
8+
* @precision low
89
* @tags security
910
* external/cwe/cwe-502
1011
*/
1112

12-
/*
13-
* consider: @precision low
14-
*/
15-
1613
import csharp
17-
import UnsafeDeserialization::UnsafeDeserialization
14+
import semmle.code.csharp.security.dataflow.UnsafeDeserialization::UnsafeDeserialization
1815

1916
from Call deserializeCall, Sink sink
2017
where deserializeCall.getAnArgument() = sink.asExpr()

csharp/ql/src/Security Features/CWE-502/UnsafeDeserializationUntrustedInput.qhelp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<overview>
66

77
<p>Deserializing an object from untrusted input may result in security problems, such
8-
as denial-of-service or remote code execution.</p>
8+
as denial of service or remote code execution.</p>
99

1010
</overview>
1111
<recommendation>

csharp/ql/src/Security Features/CWE-502/UnsafeDeserializationUntrustedInput.ql

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,13 @@
55
* @kind path-problem
66
* @id cs/unsafe-deserialization-untrusted-input
77
* @problem.severity error
8+
* @precision high
89
* @tags security
910
* external/cwe/cwe-502
1011
*/
1112

12-
/*
13-
* consider: @precision high
14-
*/
15-
1613
import csharp
17-
import UnsafeDeserialization::UnsafeDeserialization
14+
import semmle.code.csharp.security.dataflow.UnsafeDeserialization::UnsafeDeserialization
1815
import DataFlow::PathGraph
1916

2017
from TaintTrackingConfig config, DataFlow::PathNode source, DataFlow::PathNode sink

csharp/ql/src/Security Features/CWE-502/UnsafeDeserialization.qll renamed to csharp/ql/src/semmle/code/csharp/security/dataflow/UnsafeDeserialization.qll

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
import csharp
77

88
module UnsafeDeserialization {
9-
private import semmle.code.csharp.dataflow.flowsources.Remote
109
private import semmle.code.csharp.dataflow.flowsources.Remote
1110
private import semmle.code.csharp.serialization.Deserializers
1211

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
// semmle-extractor-options: /r:System.Runtime.Extensions.dll /r:System.IO.FileSystem.dll
1+
// semmle-extractor-options: /r:System.Runtime.Extensions.dll /r:System.IO.FileSystem.dll /r:System.Collections.Specialized.dll ${testdir}/../../../../resources/stubs/System.Web.cs

csharp/ql/test/query-tests/Security Features/CWE-502/UnsafeDeserialization/SystemWebStub.cs

Lines changed: 0 additions & 34 deletions
This file was deleted.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
// semmle-extractor-options: /r:System.Runtime.Extensions.dll /r:System.IO.FileSystem.dll
1+
// semmle-extractor-options: /r:System.Runtime.Extensions.dll /r:System.IO.FileSystem.dll /r:System.Collections.Specialized.dll ${testdir}/../../../../resources/stubs/System.Web.cs

csharp/ql/test/query-tests/Security Features/CWE-502/UnsafeDeserializationUntrustedInput/SystemWebStub.cs

Lines changed: 0 additions & 45 deletions
This file was deleted.

0 commit comments

Comments
 (0)