A01—Broken Access Control
>Control Description
>Prevention & Mitigation Strategies
- 1.Except for public resources, deny by default.
- 2.Implement access control mechanisms once and reuse them throughout the application, including minimizing Cross-Origin Resource Sharing (CORS) usage.
- 3.Model access controls should enforce record ownership rather than allowing users to create, read, update, or delete any record.
- 4.Unique application business limit requirements should be enforced by domain models.
- 5.Disable web server directory listing and ensure file metadata (e.g., .git) and backup files are not present within web roots.
- 6.Log access control failures, alert admins when appropriate (e.g., repeated failures).
- 7.Implement rate limits on API and controller access to minimize the harm from automated attack tooling.
- 8.Stateful session identifiers should be invalidated on the server after logout. Stateless JWT tokens should be short-lived to minimize the window of opportunity for an attacker. For longer-lived JWTs, consider using refresh tokens and following OAuth standards to revoke access.
- 9.Use well-established toolkits or patterns that provide simple, declarative access controls.
>Attack Scenarios
The application uses unverified data in an SQL call that is accessing account information: ``` pstmt.setString(1, request.getParameter("acct")); ResultSet results = pstmt.executeQuery( ); ``` An attacker can simply modify the browser's 'acct' parameter to send any desired account number. If not correctly verified, the attacker can access any user's account. ``` https://example.com/app/accountInfo?acct=notmyacct ```
An attacker simply forces browsers to target URLs. Admin rights are required for access to the admin page. ``` https://example.com/app/getappInfo https://example.com/app/admin_getappInfo ``` If an unauthenticated user can access either page, it's a flaw. If a non-admin can access the admin page, this is a flaw.
An application puts all of their access control in their front-end. While the attacker cannot get to `https://example.com/app/admin_getappInfo` due to JavaScript code running in the browser, they can simply execute: ``` $ curl https://example.com/app/admin_getappInfo ``` from the command line.
>Related CWEs
>References
Ask AI
Configure your API key to use AI features.