AI pentesting guides / By tech stack

Stack guide: .NET

ASP.NET Core security testing

ASP.NET Core security testing checks that authorisation attributes and policies cover every endpoint, that model binding does not accept fields it should not, and that the hosting stack, Kestrel plus whatever proxy sits in front of it, parses requests consistently.

The framework provides good defaults, including antiforgery for Razor forms and data protection for cookies, so findings concentrate in controllers and minimal APIs that were added without the same care.

Authorisation coverage

  • Controllers without [Authorize], or actions marked [AllowAnonymous] inside a protected controller, are public.
  • Minimal API endpoints need RequireAuthorization(); a global fallback policy is the safer default.
  • Role or policy checks that do not compare the resource owner to the caller leave BOLA open.
  • Multi-tenant apps that rely on a tenant ID from the request body rather than the token.

Over-posting and model binding

Binding a request directly to an Entity Framework entity lets clients set any public property, such as IsAdmin or TenantId. Separate input DTOs, or [Bind] lists on Razor Pages, prevent it. Testers add unexpected JSON properties and check whether they persist.

Kestrel, proxies and error handling

  • CVE-2025-55315 (October 2025) was an HTTP request smuggling flaw in Kestrel's handling of chunked encoding; Microsoft rated it 9.9 and fixed it in 8.0.21, 9.0.10 and the .NET 10 release candidate.
  • Smuggling risk depends on the proxy in front, so test the real chain: CDN, load balancer, reverse proxy and Kestrel.
  • UseDeveloperExceptionPage left enabled outside Development shows stack traces.
  • Swagger UI (Swashbuckle) at /swagger and its JSON at /swagger/v1/swagger.json often stay enabled in production.

Identity, cookies and tokens

ASP.NET Core Identity handles password hashing and lockout well, but configuration still matters: lockout disabled, long-lived cookies without sliding expiry, or JWT bearer validation with ValidateIssuer or ValidateAudience turned off. Apps that accept tokens from several identity providers should be tested with a valid token from one tenant against another. SignalR hubs need the same [Authorize] coverage as controllers.

With Pentest-Swarm

Testing ASP.NET Core with Pentest-Swarm

Pentest-Swarm tests the deployed .NET service over HTTP and does not need the solution file or assemblies.

  • Recon probes /swagger/v1/swagger.json and other common spec paths and maps documented endpoints.
  • Run api-security with a bearer token from your identity provider via --auth to test authorisation across controllers.
  • Run against the same proxy chain production uses, with scope limited to that host using --scope and --allow-ports.
  • Export SARIF from the ci-cd-security playbook to surface findings in your build pipeline.

Where it falls short

Black-box testing finds endpoints that respond without authorisation but cannot list every controller missing an attribute, and it cannot see NuGet package versions. Roslyn security analysers or another SAST tool, plus dependency scanning for ASP.NET Core runtime advisories, cover what HTTP tests cannot.

Questions

Does patching .NET fix CVE-2025-55315 everywhere?

Updating the runtime or Kestrel package fixes Kestrel's parsing. Microsoft noted that Azure App Service's proxy layer already protected hosted apps. Self-hosted apps need the update.

What is over-posting in ASP.NET Core?

It is the .NET name for mass assignment: model binding sets properties the client should not control. Use input DTOs that only contain editable fields.

Should Swagger be on in production?

Only if the API is meant to be public. Otherwise restrict it to Development or put it behind authentication.

Sources

  1. Microsoft security advisory GHSA-5rrx-jjjq-q2r5 (CVE-2025-55315)
  2. MSRC: Understanding CVE-2025-55315