Skip to content

Commit c906a82

Browse files
committed
C#: Edit qhelp for cs/insecure-request-validation-mode
1 parent 4b19f3b commit c906a82

File tree

8 files changed

+35
-48
lines changed

8 files changed

+35
-48
lines changed

csharp/ql/src/Security Features/CWE-016/ASPNetRequestValidationMode.qhelp

Lines changed: 13 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -3,84 +3,49 @@
33

44
<overview>
55
<p>
6-
The
7-
<code>requestValidationMode</code>
8-
attribute in ASP.NET is used to configure
9-
built-in validations to
10-
protect applications against code injections. Downgrading or
11-
disabling
12-
this configuration is not recommended. The default value 4.5
13-
is
14-
the only recommended value as previous versions only
15-
test a subset
16-
of
17-
requests.
6+
The <code>requestValidationMode</code> attribute in ASP.NET is used to configure built in validation to
7+
protect applications against code injections. Downgrading or disabling
8+
this configuration is not recommended. The default value of 4.5
9+
is the only recommended value as previous versions only test a subset of requests.
1810
</p>
1911

2012
</overview>
2113
<recommendation>
2214

2315
<p>
24-
Always set
25-
<code>requestValidationMode</code>
26-
to 4.5. (Default value)
16+
Always set <code>requestValidationMode</code> to 4.5, or leave it at its default value.
2717
</p>
2818

2919
</recommendation>
3020
<example>
3121

3222
<p>
33-
The following example shows the
34-
<code>requestValidationMode</code>
23+
The following example shows the <code>requestValidationMode</code>
3524
attribute set to the value 4.0 which disables some protections and
36-
ignores individual
37-
<code>Page</code>
38-
directives:
39-
<code>
40-
<httpRuntime requestValidationMode="4.0" />
25+
ignores individual <code>Page</code> directives:
4126

42-
43-
44-
</code>
27+
<sample src="ConfigurationBad.config" />
4528
</p>
4629

4730
<p>
48-
If the value is set to 2.0, request validation is enabled for pages
49-
but not for all requests:
31+
Setting the value to 4.5 enables request validation for all requests:
5032
</p>
5133

52-
<code>
53-
<httpRuntime requestValidationMode="2.0" />
54-
55-
56-
57-
</code>
58-
59-
<p>
60-
If the value is set to 0, request validation is completely disabled
61-
(Only recognized in ASP.NET 4.6 and later):
62-
</p>
63-
64-
<code>
65-
<httpRuntime requestValidationMode="0.0" />
66-
67-
34+
<sample src="ConfigurationGood.config" />
6835

69-
</code>
7036
</example>
7137
<references>
7238

7339
<li>
7440
Microsoft:
7541
<a
76-
href="https://docs.microsoft.com/en-us/dotnet/api/system.web.configuration.httpruntimesection.requestvalidationmode?view=netframework-4.8">requestValidationMode configuration to protect against code
77-
injection attacks</a>
78-
.
42+
href="https://docs.microsoft.com/en-us/dotnet/api/system.web.configuration.httpruntimesection.requestvalidationmode?view=netframework-4.8">HttpRuntimeSection.RequestValidationMode Property
43+
</a>.
7944
</li>
8045
<li>
8146
OWASP:
8247
<a
83-
href="https://www.owasp.org/index.php/ASP.NET_Request_Validation">ASP.NET Request Validation on OWASP</a>
48+
href="https://www.owasp.org/index.php/ASP.NET_Request_Validation">ASP.NET Request Validation</a>.
8449
</li>
8550
</references>
8651

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<configuration>
2+
<system.web>
3+
<httpRuntime requestValidationMode="4.0"/>
4+
</system.web>
5+
</configuration>
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<configuration>
2+
<system.web>
3+
<httpRuntime requestValidationMode="4.5"/>
4+
</system.web>
5+
</configuration>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
| ConfigurationBad.config:3:5:3:47 | requestValidationMode=4.0 | Insecure value for requestValidationMode (4.0). |
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Security Features/CWE-016/ASPNetRequestValidationMode.ql
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<configuration>
2+
<system.web>
3+
<httpRuntime requestValidationMode="4.0"/>
4+
</system.web>
5+
</configuration>
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<configuration>
2+
<system.web>
3+
<httpRuntime requestValidationMode="4.5"/>
4+
</system.web>
5+
</configuration>

csharp/ql/test/query-tests/Security Features/CWE-016/ASPNetRequestValidationMode/Program.cs

Whitespace-only changes.

0 commit comments

Comments
 (0)