Stack Trace Exposure High

Stacktrace information is displayed in a non-development environment.

Detector ID
csharp/stack-trace-exposure@v1.0
Category
Common Weakness Enumeration (CWE) external icon
Tags
-

Noncompliant example

1public void StackTraceExposureNoncompliant(IApplicationBuilder application, IHostEnvironment environment)
2{
3    if (!environment.IsDevelopment())
4    {
5        // Noncompliant: Stacktrace information is displayed in a non-Development environment.
6        application.UseDeveloperExceptionPage();
7    }
8    else
9    {
10        application.UseExceptionHandler("/Error");
11    }
12}

Compliant example

1public void StackTraceExposureCompliant(IApplicationBuilder application, IHostEnvironment environment)
2{
3    if (environment.IsDevelopment())
4    {
5        // Compliant: Stacktrace information is displayed in a Development environment.
6        application.UseDeveloperExceptionPage();
7    }
8    else
9    {
10        application.UseExceptionHandler("/Error");
11    }
12}