The developer exception page is enabled without checking that the app runs in development

tx0/csharp:unguarded-developer-exception-pagerecommendedwarningsecurity/configurationdepth fastsecurity, cwe-489

What it finds

UseDeveloperExceptionPage shows stack traces, source lines and request details to whoever triggers an error. Outside a check of IsDevelopment(), it is also enabled in production. Recent ASP.NET Core templates enable it in development by themselves.

From the rule's source, unguarded_developer_exception_page.rs.

Example from the rule's tests
using Microsoft.AspNetCore.Builder;using Microsoft.AspNetCore.Hosting; class Startup{    void Configure(IApplicationBuilder app, IWebHostEnvironment env)    {        app.UseDeveloperExceptionPage();tx0 reports: UseDeveloperExceptionPage is enabled in every environment        if (env.IsDevelopment())        {            app.UseDeveloperExceptionPage();        }    }}
Highlighted lines are the ones tx0 reports, with its message under each; the other lines are left alone.

Turn it on, off or suppress it

The rule runs from the recommended tier up. To turn it on in a lower tier, give it a level in tx0.toml:

tx0.toml
[rules]
"tx0/csharp:unguarded-developer-exception-page" = "warning"

To keep one finding, suppress it with a reason. tx0 suppress ID --reason "..." writes the comment on the line before the code:

// tx0: ignore[tx0/csharp:unguarded-developer-exception-page] reason="..."

tx0 explain tx0/csharp:unguarded-developer-exception-page shows the same in the terminal. Found a false positive? Report it.