Zum Inhalt springen

Permissive CORS (ARCH323)

Dieser Inhalt ist noch nicht in deiner Sprache verfügbar.

Key dotnet.security.permissive-cors · Severity error · Category security · CWE CWE-942

When AllowAnyOrigin is combined with AllowCredentials, any origin can make requests with credentials (cookies/tokens). This exposes user sessions to malicious sites.

builder.Services.AddCors(o => o.AddDefaultPolicy(p =>
p.AllowAnyOrigin()
.AllowAnyHeader()
.AllowCredentials()));
builder.Services.AddCors(o => o.AddDefaultPolicy(p =>
p.WithOrigins("https://app.example.com")
.AllowAnyHeader()
.AllowCredentials()));

When credentials are required, replace AllowAnyOrigin with WithOrigins and explicitly list trusted origins.