ASP.Net Custom Errors Disabled
ID |
csharp.custom_errors_disabled |
Severity |
high |
Resource |
Misconfiguration |
Language |
CSharp |
Tags |
CWE:209, NIST.SP.800-53, OWASP:2021:A7, PCI-DSS:6.5.3, aspnet |
Description
Disabling custom error pages in ASP.NET applications can reveal detailed error information to end users, posing a security risk.
Rationale
The custom error setting in an ASP.NET application determines what users see when an unhandled exception occurs. If customErrors mode is set to "Off", users will receive detailed error information that can be leveraged by malicious actors to identify vulnerabilities in the application.
Often, this detailed error display includes stack traces, configuration details, and possibly sensitive file locations.
An example of unsafe configuration:
<customErrors mode="Off" />
In environments where customErrors
is set to Off
, the application will expose detailed error messages to end users, instead of offering a user-friendly and secure error page. This can aid attackers in reconnaissance and furthering their exploitation attempts.
Remediation
To mitigate this risk, configure your ASP.NET application to use custom error pages by setting the customErrors
mode to RemoteOnly
or On
. This way, detailed error information is only available locally to developers or administrators and not exposed to end users.
<customErrors mode="RemoteOnly" defaultRedirect="ErrorPage.aspx" />
References
-
CWE-209 : Generation of Error Message Containing Sensitive Information.