C Sharp Override Auth Modifier
Description
Detects potential authorization bypass vulnerabilities in C# code where methods are marked with [AllowAnonymous] while being in a class that has authorization requirements. This misconfiguration could allow unauthorized access to protected functionality.
Detection Strategy
• Look for C# method declarations in the code
• Check if the method is within a class that has authorization requirements (like [Authorize] attribute)
• Verify if the method is marked with the [AllowAnonymous] attribute
• Report a vulnerability if a method with [AllowAnonymous] exists in an authorized class, as this could create unintended security bypasses
Vulnerable code example
[AllowAnonymous] // Dangerous: Allows unauthenticated access to entire controller
public class AdminController : Controller
{
public ActionResult SensitiveData()
{
return View(GetConfidentialRecords());
}
}✅ Secure code example
[Authorize] // Secure: Requires authentication for all actions by default
public class AdminController : Controller
{
[Authorize(Roles = "Admin")] // Additional protection: Requires Admin role for sensitive data
public ActionResult SensitiveData()
{
return View(GetConfidentialRecords());
}...Search for vulnerabilities in your apps for free with Fluid Attacks' automated security testing! Start your 21-day free trial and discover the benefits of the Continuous Hacking Essential plan. If you prefer the Advanced plan, which includes the expertise of Fluid Attacks' hacking team, fill out this contact form.