تخطَّ إلى المحتوى

AllowAnonymous on sensitive endpoint (ARCH321)

هذا المحتوى غير متوفر بلغتك بعد.

Key dotnet.security.allow-anonymous-on-sensitive · Severity warning · Category security · CWE CWE-862

Applying [AllowAnonymous] to an action that performs sensitive operations disables authentication and authorization entirely. This can allow unauthorized users to reach resources that should be protected.

[AllowAnonymous]
[HttpPost("admin/delete-user")]
public IActionResult DeleteUser(int id)
{
_users.Delete(id);
return Ok();
}
[Authorize(Roles = "Admin")]
[HttpPost("admin/delete-user")]
public IActionResult DeleteUser(int id)
{
_users.Delete(id);
return Ok();
}

Remove [AllowAnonymous] from sensitive endpoints and apply the appropriate role- or policy-based [Authorize] rule.