Improper privilege management

Improper Privilege Management

Description

Incorrect assignment, modification, tracking, or review of privileges can allow access or actions beyond what is needed.

Potential impact

  • An attacker may gain excessive privileges, perform unauthorized actions, or act as another user.

Remediation

  1. Follow least privilege: grant users and processes only the permissions they need.
  2. Manage permissions through role-based access control (RBAC).
  3. Log privilege changes and review them regularly.
  4. Require an established approval process for privilege changes.

These examples assume method security is enabled, for example with @EnableMethodSecurity, and calls pass through the security proxy of a Spring-managed bean.

Examples

Before

java
@PreAuthorize("hasRole('USER')")
public void performAdminTask() {
    // Perform the administrative operation
}

After

java
@PreAuthorize("hasRole('ADMIN')")
public void performAdminTask() {
    // Perform the administrative operation
}

Explanation:

  • Before: The USER role is sufficient to run an administrative operation.
  • After: Access to this method requires the ADMIN role. Assign that role only to appropriate users.

Related CVEs

References