Broken Access Control
What is Broken Access Control
Access control, sometimes called authorization, is how a web application grants access to content and functions to some users and not others. These checks are performed after authentication, and govern what ‘authorized’ users are allowed to do. A web application’s access control model is closely tied to the content and functions that the site provides. In addition, the users may fall into a number of groups or roles with different abilities or privileges. Access control enforces policy such that users cannot act outside of their intended permissions. Failures typically lead to unauthorized information disclosure, modification, or destruction of all data or performing a business function outside the user's limits. Common access control vulnerabilities include:
- Violation of the principle of least privilege or deny by default, where access should only be granted for particular capabilities, roles, or users, but is available to anyone.
- Bypassing access control checks by modifying the URL (parameter tampering or force browsing), internal application state, or the HTML page, or by using an attack tool modifying API requests.
- Permitting viewing or editing someone else's account, by providing its unique identifier (insecure direct object references)
- Accessing API with missing access controls for POST, PUT and DELETE.
- Elevation of privilege. Acting as a user without being logged in or acting as an admin when logged in as a user.
- CORS misconfiguration allows API access from unauthorized/untrusted origins.
- Force browsing to authenticated pages as an unauthenticated user or to privileged pages as a standard user.
This lab helps us to understand one of the authentication flaws which leads to an attacker gaining
unauthorized control of an account.
On accessing the lab the user is provided with a simple login in page which requires a username and
password.
The credentials for the user Jack is jack:jacktheripper.
Use the above info to log in.
The main aim of this lab is to login with admin privileges to get the secret key.
Exploiting the Broken Access
- Every time a valid user logs in,the user session is set with a cookie called
admin - When you notice the cookie value when logged in as
jackit is set to 0 - Use BurpSuite to intercept the request change the value of the admin cookie from 0 to 1
- This should log you in as a admin user and display the secret key
This lab helps us to understand one of the authentication flaws which leads to an attacker gaining
unauthorized control of an account.
The credentials for the user Jack is jack:jacktheripper.
Use the above info to log in.
The main aim of this lab is to login with admin privileges to get the secret key.
Exploiting the Broken Access
- Log in Using the credentials provided above
- Search for information lying around in the source files
- You'll find out that user agent needs to be
pygoat_admin - Use BurpSuite to intercept the request and change headers
User-Agentto value pygoat_admin
user : admin
password : admin_pass
this is the admin credential
and
user : John
password : reaper
this is regular user credential
can u get access to admin page contents using regular user credentials or without credentials ?
Mitigation
- Except for public resources, deny by default.
- Implement access control mechanisms once and re-use them throughout the application, including minimizing Cross-Origin Resource Sharing (CORS) usage.
- Model access controls should enforce record ownership rather than accepting that the user can create, read, update, or delete any record.
- Unique application business limit requirements should be enforced by domain models
- Disable web server directory listing and ensure file metadata (e.g., .git) and backup files are not present within web roots
- Log access control failures, alert admins when appropriate (e.g., repeated failures)
- Rate limit API and controller access to minimize the harm from automated attack tooling
- Stateful session identifiers should be invalidated on the server after logout. Stateless JWT tokens should rather be short-lived so that the window of opportunity for an attacker is minimized. For longer lived JWTs it's highy recommended to follow the OAuth standards to revoke access.