2021-01-22 04:06:24 +00:00
|
|
|
include::../description.adoc[]
|
|
|
|
|
|
|
|
include::../ask-yourself.adoc[]
|
|
|
|
|
|
|
|
include::../recommended.adoc[]
|
|
|
|
|
|
|
|
== Sensitive Code Example
|
|
|
|
|
|
|
|
----
|
|
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
|
|
|
|
public class MyController : Controller
|
|
|
|
{
|
|
|
|
[HttpPost]
|
|
|
|
[DisableRequestSizeLimit] // Sensitive: No size limit
|
2021-02-12 16:35:24 +01:00
|
|
|
[RequestSizeLimit(10000000)] // Sensitive: 10MB is more than the recommended limit of 8MB
|
2021-01-23 04:07:47 +00:00
|
|
|
public IActionResult PostRequest(Model model)
|
|
|
|
{
|
2021-01-22 04:06:24 +00:00
|
|
|
// ...
|
|
|
|
}
|
|
|
|
|
|
|
|
[HttpPost]
|
|
|
|
[RequestFormLimits(MultipartBodyLengthLimit = 8000000)] // Sensitive: 10MB is more than the recommended limit of 8MB
|
|
|
|
public IActionResult MultipartFormRequest(Model model)
|
|
|
|
{
|
|
|
|
// ...
|
|
|
|
}
|
|
|
|
}
|
|
|
|
----
|
|
|
|
|
2021-06-21 12:01:33 +02:00
|
|
|
In Web.config:
|
2021-04-26 17:29:13 +02:00
|
|
|
|
|
|
|
----
|
|
|
|
<configuration>
|
|
|
|
<system.web>
|
|
|
|
<httpRuntime maxRequestLength="81920" executionTimeout="3600" />
|
|
|
|
<!-- Sensitive: maxRequestLength is exprimed in KB, so 81920KB = 80MB -->
|
|
|
|
</system.web>
|
|
|
|
<system.webServer>
|
|
|
|
<security>
|
|
|
|
<requestFiltering>
|
|
|
|
<requestLimits maxAllowedContentLength="83886080" />
|
|
|
|
<!-- Sensitive: maxAllowedContentLength is exprimed in bytes, so 83886080B = 80MB -->
|
|
|
|
</requestFiltering>
|
|
|
|
</security>
|
|
|
|
</system.webServer>
|
|
|
|
</configuration>
|
|
|
|
----
|
|
|
|
|
2021-01-22 04:06:24 +00:00
|
|
|
== Compliant Solution
|
|
|
|
|
2022-02-04 17:28:24 +01:00
|
|
|
[source,csharp]
|
2021-01-22 04:06:24 +00:00
|
|
|
----
|
|
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
|
|
|
|
public class MyController : Controller
|
|
|
|
{
|
|
|
|
[HttpPost]
|
2021-02-12 16:35:24 +01:00
|
|
|
[RequestSizeLimit(8000000)] // Compliant: 8MB
|
2021-01-22 04:06:24 +00:00
|
|
|
public IActionResult PostRequest(Model model)
|
|
|
|
{
|
|
|
|
// ...
|
|
|
|
}
|
|
|
|
|
|
|
|
[HttpPost]
|
|
|
|
[RequestFormLimits(MultipartBodyLengthLimit = 8000000)] // Compliant: 8MB
|
|
|
|
public IActionResult MultipartFormRequest(Model model)
|
|
|
|
{
|
|
|
|
// ...
|
|
|
|
}
|
|
|
|
}
|
|
|
|
----
|
|
|
|
|
2021-06-21 12:01:33 +02:00
|
|
|
In Web.config:
|
2021-04-26 17:29:13 +02:00
|
|
|
|
2022-02-04 17:28:24 +01:00
|
|
|
[source,csharp]
|
2021-04-26 17:29:13 +02:00
|
|
|
----
|
|
|
|
<configuration>
|
|
|
|
<system.web>
|
|
|
|
<httpRuntime maxRequestLength="8192" executionTimeout="3600" />
|
|
|
|
<!-- Compliant: maxRequestLength is exprimed in KB, so 8192KB = 8MB -->
|
|
|
|
</system.web>
|
|
|
|
<system.webServer>
|
|
|
|
<security>
|
|
|
|
<requestFiltering>
|
|
|
|
<requestLimits maxAllowedContentLength="8388608" />
|
|
|
|
<!-- Comliant: maxAllowedContentLength is exprimed in bytes, so 8388608B = 8MB -->
|
|
|
|
</requestFiltering>
|
|
|
|
</security>
|
|
|
|
</system.webServer>
|
|
|
|
</configuration>
|
|
|
|
----
|
|
|
|
|
2021-01-22 04:06:24 +00:00
|
|
|
include::../see.adoc[]
|
2021-06-21 13:30:34 +02:00
|
|
|
|
2021-06-21 12:01:33 +02:00
|
|
|
* https://docs.microsoft.com/en-us/aspnet/core/host-and-deploy/iis/web-config[Web.config] - XML-formatted config file for IIS applications
|
2021-06-02 20:44:38 +02:00
|
|
|
|
2021-06-03 09:05:38 +02:00
|
|
|
ifdef::env-github,rspecator-view[]
|
2021-09-20 15:38:42 +02:00
|
|
|
|
|
|
|
'''
|
|
|
|
== Implementation Specification
|
|
|
|
(visible only on this page)
|
|
|
|
|
|
|
|
include::../message.adoc[]
|
|
|
|
|
2023-05-25 14:18:12 +02:00
|
|
|
=== Parameters
|
|
|
|
|
|
|
|
.fileUploadSizeLimit
|
|
|
|
****
|
|
|
|
_integer_
|
|
|
|
|
|
|
|
----
|
|
|
|
8000000
|
|
|
|
----
|
|
|
|
|
|
|
|
The maximum size of HTTP requests handling file uploads (in bytes)
|
|
|
|
****
|
|
|
|
|
2021-09-20 15:38:42 +02:00
|
|
|
|
2021-06-08 15:52:13 +02:00
|
|
|
'''
|
2021-06-02 20:44:38 +02:00
|
|
|
== Comments And Links
|
|
|
|
(visible only on this page)
|
|
|
|
|
|
|
|
include::../comments-and-links.adoc[]
|
2021-06-03 09:05:38 +02:00
|
|
|
endif::env-github,rspecator-view[]
|