API5—Broken Function Level Authorization
>Control Description
>Prevention & Mitigation Strategies
- 1.The enforcement mechanism(s) should deny all access by default, requiring explicit grants to specific roles for access to every function.
- 2.Review your API endpoints against function level authorization flaws, while keeping in mind the business logic of the application and groups hierarchy.
- 3.Make sure that all of your administrative controllers inherit from an administrative abstract controller that implements authorization checks based on the user's group/role.
- 4.Make sure that administrative functions inside a regular controller implement authorization checks based on the user's group and role.
>Attack Scenarios
During the registration process for an application that only allows invited users to join, the mobile application triggers an API call to GET /api/invites/{invite_guid}. The attacker discovers this endpoint and manipulates it to POST /api/invites/new, which is an administrative endpoint that should not be accessible to regular users. Because the endpoint doesn't implement function level authorization checks, the attacker creates an invite and grants themselves admin privileges.
An attacker identifies an administrative API endpoint GET /api/admin/v1/users/all by guessing common URL patterns. Because the endpoint does not implement function level authorization checks, the attacker gains access to sensitive details of all users in the system.
>Related CWEs
>References
Ask AI
Configure your API key to use AI features.