Skip to content

Commit d97df27

Browse files
authored
Merge pull request #5594 from MicrosoftDocs/master637303658139836941
For protected CLA branch, push strategy should use PR and merge to target branch method to work around git push error
2 parents 326c8c9 + d7ad457 commit d97df27

File tree

64 files changed

+726
-91
lines changed

Some content is hidden

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

64 files changed

+726
-91
lines changed

docs/code-quality/ca2350.md

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
---
2+
title: "CA2350: Ensure DataTable.ReadXml()'s input is trusted"
3+
ms.date: 07/14/2020
4+
ms.topic: reference
5+
author: dotpaul
6+
ms.author: paulming
7+
manager: jillfra
8+
dev_langs:
9+
- CSharp
10+
ms.workload:
11+
- "multiple"
12+
f1_keywords:
13+
- "CA2350"
14+
---
15+
# CA2350: Ensure DataTable.ReadXml()'s input is trusted
16+
17+
|Item|Value|
18+
|-|-|
19+
|CheckId|CA2350|
20+
|Category|Microsoft.Security|
21+
|Breaking change|Non-breaking|
22+
23+
## Cause
24+
25+
The <xref:System.Data.DataTable.ReadXml%2A?displayProperty=nameWithType> method was called or referenced.
26+
27+
## Rule description
28+
29+
When deserializing a <xref:System.Data.DataTable> with untrusted input, an attacker can craft malicious input to perform a denial of service attack. There may be unknown remote code execution vulnerabilities.
30+
31+
For more information, see [DataSet and DataTable security guidance](https://go.microsoft.com/fwlink/?linkid=2132227).
32+
33+
## How to fix violations
34+
35+
- If possible, use [Entity Framework](https://docs.microsoft.com/ef/) rather than the <xref:System.Data.DataTable>.
36+
- Make the serialized data tamper-proof. After serialization, cryptographically sign the serialized data. Before deserialization, validate the cryptographic signature. Protect the cryptographic key from being disclosed and design for key rotations.
37+
38+
## When to suppress warnings
39+
40+
[!INCLUDE[insecure-deserializers-common-safe-to-suppress](includes/insecure-deserializers-common-safe-to-suppress-md.md)]
41+
42+
## Pseudo-code examples
43+
44+
### Violation
45+
46+
```csharp
47+
using System.Data;
48+
49+
public class ExampleClass
50+
{
51+
public DataTable MyDeserialize(string untrustedXml)
52+
{
53+
DataTable dt = new DataTable();
54+
dt.ReadXml(untrustedXml);
55+
}
56+
}
57+
```
58+
59+
## Related rules
60+
61+
[CA2351: Ensure DataSet.ReadXml()'s input is trusted](ca2351.md)
62+
63+
[CA2352: Unsafe DataSet or DataTable in serializable type can be vulnerable to remote code execution attacks](ca2352.md)
64+
65+
[CA2353: Unsafe DataSet or DataTable in serializable type](ca2353.md)
66+
67+
[CA2354: Unsafe DataSet or DataTable in deserialized object graph can be vulnerable to remote code execution attack](ca2354.md)
68+
69+
[CA2355: Unsafe DataSet or DataTable in deserialized object graph](ca2355.md)
70+
71+
[CA2356: Unsafe DataSet or DataTable in web deserialized object graph](ca2356.md)

docs/code-quality/ca2351.md

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
---
2+
title: "CA2351: Ensure DataSet.ReadXml()'s input is trusted"
3+
ms.date: 07/14/2020
4+
ms.topic: reference
5+
author: dotpaul
6+
ms.author: paulming
7+
manager: jillfra
8+
dev_langs:
9+
- CSharp
10+
ms.workload:
11+
- "multiple"
12+
f1_keywords:
13+
- "CA2351"
14+
---
15+
# CA2351: Ensure DataSet.ReadXml()'s input is trusted
16+
17+
|Item|Value|
18+
|-|-|
19+
|CheckId|CA2351|
20+
|Category|Microsoft.Security|
21+
|Breaking change|Non-breaking|
22+
23+
## Cause
24+
25+
The <xref:System.Data.DataSet.ReadXml%2A?displayProperty=nameWithType> method was called or referenced.
26+
27+
## Rule description
28+
29+
When deserializing a <xref:System.Data.DataSet> with untrusted input, an attacker can craft malicious input to perform a denial of service attack. There may be unknown remote code execution vulnerabilities.
30+
31+
For more information, see [DataSet and DataTable security guidance](https://go.microsoft.com/fwlink/?linkid=2132227).
32+
33+
## How to fix violations
34+
35+
- If possible, use [Entity Framework](https://docs.microsoft.com/ef/) rather than the <xref:System.Data.DataSet>.
36+
- Make the serialized data tamper-proof. After serialization, cryptographically sign the serialized data. Before deserialization, validate the cryptographic signature. Protect the cryptographic key from being disclosed and design for key rotations.
37+
38+
## When to suppress warnings
39+
40+
[!INCLUDE[insecure-deserializers-common-safe-to-suppress](includes/insecure-deserializers-common-safe-to-suppress-md.md)]
41+
42+
## Pseudo-code examples
43+
44+
### Violation
45+
46+
```csharp
47+
using System.Data;
48+
49+
public class ExampleClass
50+
{
51+
public DataSet MyDeserialize(string untrustedXml)
52+
{
53+
DataSet dt = new DataSet();
54+
dt.ReadXml(untrustedXml);
55+
}
56+
}
57+
```
58+
59+
## Related rules
60+
61+
[CA2350: Ensure DataTable.ReadXml()'s input is trusted](ca2350.md)
62+
63+
[CA2352: Unsafe DataSet or DataTable in serializable type can be vulnerable to remote code execution attacks](ca2352.md)
64+
65+
[CA2353: Unsafe DataSet or DataTable in serializable type](ca2353.md)
66+
67+
[CA2354: Unsafe DataSet or DataTable in deserialized object graph can be vulnerable to remote code execution attack](ca2354.md)
68+
69+
[CA2355: Unsafe DataSet or DataTable in deserialized object graph](ca2355.md)
70+
71+
[CA2356: Unsafe DataSet or DataTable in web deserialized object graph](ca2356.md)

docs/code-quality/ca2352.md

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
---
2+
title: "CA2352: Unsafe DataSet or DataTable in serializable type can be vulnerable to remote code execution attacks"
3+
ms.date: 07/14/2020
4+
ms.topic: reference
5+
author: dotpaul
6+
ms.author: paulming
7+
manager: jillfra
8+
dev_langs:
9+
- CSharp
10+
ms.workload:
11+
- "multiple"
12+
f1_keywords:
13+
- "CA2352"
14+
---
15+
# CA2352: Unsafe DataSet or DataTable in serializable type can be vulnerable to remote code execution attacks
16+
17+
|Item|Value|
18+
|-|-|
19+
|CheckId|CA2352|
20+
|Category|Microsoft.Security|
21+
|Breaking change|Non-breaking|
22+
23+
## Cause
24+
25+
A class or struct marked with <xref:System.SerializableAttribute> contains a <xref:System.Data.DataSet> or <xref:System.Data.DataTable> field or property, and doesn't have a <xref:System.CodeDom.Compiler.GeneratedCodeAttribute>.
26+
27+
## Rule description
28+
29+
When deserializing untrusted input with <xref:System.Runtime.Serialization.Formatters.Binary.BinaryFormatter> and the deserialized object graph contains a <xref:System.Data.DataSet> or <xref:System.Data.DataTable>, an attacker can craft a malicious payload to perform a remote code execution attack.
30+
31+
For more information, see [DataSet and DataTable security guidance](https://go.microsoft.com/fwlink/?linkid=2132227).
32+
33+
## How to fix violations
34+
35+
- If possible, use [Entity Framework](https://docs.microsoft.com/ef/) rather than <xref:System.Data.DataSet> and <xref:System.Data.DataTable>.
36+
- Make the serialized data tamper-proof. After serialization, cryptographically sign the serialized data. Before deserialization, validate the cryptographic signature. Protect the cryptographic key from being disclosed and design for key rotations.
37+
38+
## When to suppress warnings
39+
40+
[!INCLUDE[insecure-deserializers-common-safe-to-suppress](includes/insecure-deserializers-common-safe-to-suppress-md.md)]
41+
42+
## Pseudo-code examples
43+
44+
### Violation
45+
46+
```csharp
47+
using System.Data;
48+
using System.Runtime.Serialization;
49+
50+
[Serializable]
51+
public class MyClass
52+
{
53+
public DataSet MyDataSet { get; set; }
54+
}
55+
```
56+
57+
## Related rules
58+
59+
[CA2350: Ensure DataTable.ReadXml()'s input is trusted](ca2350.md)
60+
61+
[CA2351: Ensure DataSet.ReadXml()'s input is trusted](ca2351.md)
62+
63+
[CA2353: Unsafe DataSet or DataTable in serializable type](ca2353.md)
64+
65+
[CA2354: Unsafe DataSet or DataTable in deserialized object graph can be vulnerable to remote code execution attack](ca2354.md)
66+
67+
[CA2355: Unsafe DataSet or DataTable in deserialized object graph](ca2355.md)
68+
69+
[CA2356: Unsafe DataSet or DataTable in web deserialized object graph](ca2356.md)

docs/code-quality/ca2353.md

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
---
2+
title: "CA2353: Unsafe DataSet or DataTable in serializable type"
3+
ms.date: 07/14/2020
4+
ms.topic: reference
5+
author: dotpaul
6+
ms.author: paulming
7+
manager: jillfra
8+
dev_langs:
9+
- CSharp
10+
ms.workload:
11+
- "multiple"
12+
f1_keywords:
13+
- "CA2353"
14+
---
15+
# CA2353: Unsafe DataSet or DataTable in serializable type
16+
17+
|Item|Value|
18+
|-|-|
19+
|CheckId|CA2353|
20+
|Category|Microsoft.Security|
21+
|Breaking change|Non-breaking|
22+
23+
## Cause
24+
25+
A class or struct marked with an XML serialization attribute or a data contract attribute contains a <xref:System.Data.DataSet> or <xref:System.Data.DataTable> field or property.
26+
27+
XML serialization attributes include:
28+
29+
- <xref:System.Xml.Serialization.XmlAnyAttributeAttribute>
30+
- <xref:System.Xml.Serialization.XmlAnyElementAttribute>
31+
- <xref:System.Xml.Serialization.XmlArrayAttribute>
32+
- <xref:System.Xml.Serialization.XmlArrayItemAttribute>
33+
- <xref:System.Xml.Serialization.XmlChoiceIdentifierAttribute>
34+
- <xref:System.Xml.Serialization.XmlElementAttribute>
35+
- <xref:System.Xml.Serialization.XmlEnumAttribute>
36+
- <xref:System.Xml.Serialization.XmlIgnoreAttribute>
37+
- <xref:System.Xml.Serialization.XmlIncludeAttribute>
38+
- <xref:System.Xml.Serialization.XmlRootAttribute>
39+
- <xref:System.Xml.Serialization.XmlTextAttribute>
40+
- <xref:System.Xml.Serialization.XmlTypeAttribute>
41+
42+
Data contract serialization attributes include:
43+
44+
- <xref:System.Runtime.Serialization.DataContractAttribute>
45+
- <xref:System.Runtime.Serialization.DataMemberAttribute>
46+
- <xref:System.Runtime.Serialization.IgnoreDataMemberAttribute>
47+
- <xref:System.Runtime.Serialization.KnownTypeAttribute>
48+
49+
## Rule description
50+
51+
When deserializing untrusted input and the deserialized object graph contains a <xref:System.Data.DataSet> or <xref:System.Data.DataTable>, an attacker can craft a malicious payload to perform a remote code execution attack. There may be unknown remote code execution vulnerabilities.
52+
53+
For more information, see [DataSet and DataTable security guidance](https://go.microsoft.com/fwlink/?linkid=2132227).
54+
55+
## How to fix violations
56+
57+
- If possible, use [Entity Framework](https://docs.microsoft.com/ef/) rather than <xref:System.Data.DataSet> and <xref:System.Data.DataTable>.
58+
- Make the serialized data tamper-proof. After serialization, cryptographically sign the serialized data. Before deserialization, validate the cryptographic signature. Protect the cryptographic key from being disclosed and design for key rotations.
59+
60+
## When to suppress warnings
61+
62+
[!INCLUDE[insecure-deserializers-common-safe-to-suppress](includes/insecure-deserializers-common-safe-to-suppress-md.md)]
63+
64+
## Pseudo-code examples
65+
66+
### Violation
67+
68+
```csharp
69+
using System.Data;
70+
using System.Runtime.Serialization;
71+
72+
[XmlRoot]
73+
public class MyClass
74+
{
75+
public DataSet MyDataSet { get; set; }
76+
}
77+
```
78+
79+
## Related rules
80+
81+
[CA2350: Ensure DataTable.ReadXml()'s input is trusted](ca2350.md)
82+
83+
[CA2351: Ensure DataSet.ReadXml()'s input is trusted](ca2351.md)
84+
85+
[CA2352: Unsafe DataSet or DataTable in serializable type can be vulnerable to remote code execution attacks](ca2352.md)
86+
87+
[CA2354: Unsafe DataSet or DataTable in deserialized object graph can be vulnerable to remote code execution attack](ca2354.md)
88+
89+
[CA2355: Unsafe DataSet or DataTable in deserialized object graph](ca2355.md)
90+
91+
[CA2356: Unsafe DataSet or DataTable in web deserialized object graph](ca2356.md)

docs/code-quality/ca2354.md

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
---
2+
title: "CA2354: Unsafe DataSet or DataTable in deserialized object graph can be vulnerable to remote code execution attack"
3+
ms.date: 07/14/2020
4+
ms.topic: reference
5+
author: dotpaul
6+
ms.author: paulming
7+
manager: jillfra
8+
dev_langs:
9+
- CSharp
10+
ms.workload:
11+
- "multiple"
12+
f1_keywords:
13+
- "CA2354"
14+
---
15+
# CA2354: Unsafe DataSet or DataTable in deserialized object graph can be vulnerable to remote code execution attack
16+
17+
|Item|Value|
18+
|-|-|
19+
|CheckId|CA2354|
20+
|Category|Microsoft.Security|
21+
|Breaking change|Non-breaking|
22+
23+
## Cause
24+
25+
Deserializing with an <xref:System.Runtime.Serialization.IFormatter?displayProperty=nameWithType> serialized, and the casted type's object graph can include a <xref:System.Data.DataSet> or <xref:System.Data.DataTable>.
26+
27+
This rule uses a different approach to a similar rule, [CA2352: Unsafe DataSet or DataTable in serializable type can be vulnerable to remote code execution attacks](ca2352.md).
28+
29+
## Rule description
30+
31+
When deserializing untrusted input with <xref:System.Runtime.Serialization.Formatters.Binary.BinaryFormatter> and the deserialized object graph contains a <xref:System.Data.DataSet> or <xref:System.Data.DataTable>, an attacker can craft a malicious payload to perform a remote code execution attack.
32+
33+
For more information, see [DataSet and DataTable security guidance](https://go.microsoft.com/fwlink/?linkid=2132227).
34+
35+
## How to fix violations
36+
37+
- If possible, use [Entity Framework](https://docs.microsoft.com/ef/) rather than <xref:System.Data.DataSet> and <xref:System.Data.DataTable>.
38+
- Make the serialized data tamper-proof. After serialization, cryptographically sign the serialized data. Before deserialization, validate the cryptographic signature. Protect the cryptographic key from being disclosed and design for key rotations.
39+
40+
## When to suppress warnings
41+
42+
[!INCLUDE[insecure-deserializers-common-safe-to-suppress](includes/insecure-deserializers-common-safe-to-suppress-md.md)]
43+
44+
## Pseudo-code examples
45+
46+
### Violation
47+
48+
```csharp
49+
using System.Data;
50+
using System.IO;
51+
using System.Runtime.Serialization;
52+
53+
[Serializable]
54+
public class MyClass
55+
{
56+
public MyOtherClass OtherClass { get; set; }
57+
}
58+
59+
[Serializable]
60+
public class MyOtherClass
61+
{
62+
private DataSet myDataSet;
63+
}
64+
65+
public class ExampleClass
66+
{
67+
public MyClass Deserialize(Stream stream)
68+
{
69+
BinaryFormatter bf = new BinaryFormatter();
70+
return (MyClass) bf.Deserialize(stream);
71+
}
72+
}
73+
```
74+
75+
## Related rules
76+
77+
[CA2350: Ensure DataTable.ReadXml()'s input is trusted](ca2350.md)
78+
79+
[CA2351: Ensure DataSet.ReadXml()'s input is trusted](ca2351.md)
80+
81+
[CA2352: Unsafe DataSet or DataTable in serializable type can be vulnerable to remote code execution attacks](ca2352.md)
82+
83+
[CA2353: Unsafe DataSet or DataTable in serializable type](ca2353.md)
84+
85+
[CA2355: Unsafe DataSet or DataTable in deserialized object graph](ca2355.md)
86+
87+
[CA2356: Unsafe DataSet or DataTable in web deserialized object graph](ca2356.md)

0 commit comments

Comments
 (0)