Description
For each request to a protected resource, check whether the caller may perform the requested operation on that resource.
Potential impact
Missing checks can expose data or administrative functions. Unauthorized use of limited resources may also disrupt service.
Remediation
Authenticate the caller with a framework such as Spring Security. At each protected endpoint, enforce the role, ownership or other permissions required for the operation and its target.
Examples
Before
The first controller assumes no separate URL or service-layer restriction. Add @EnableMethodSecurity to a Spring configuration class and configure authentication and role mapping.
@GetMapping("/admin")
public String getAdminPage() {
// Sensitive data or an administrator-only function
return "admin-page";
}
After
@GetMapping("/admin")
@PreAuthorize("hasRole('ROLE_ADMIN')")
public String getAdminPage() {
// Sensitive data or an administrator-only function
return "admin-page";
}
On the Spring-managed controller, @PreAuthorize checks for the administrator role (ROLE_ADMIN) before the method handles /admin.
Related CVEs
- CVE-2022-24730: Go-based continuous deployment product does not check that a user has certain privileges to update or create an app, allowing adversaries to read sensitive repository information
- CVE-2009-3168: Web application does not restrict access to admin scripts, allowing authenticated users to reset administrative passwords.
- CVE-2009-3597: Web application stores database file under the web root with insufficient access control (CWE-219), allowing direct request.