Preventing unauthorized users accessing admin path
An online shopping website, shopexample.com, has a separate admin panel accessible at shopexample.com/admin, used by administrators to manage products, orders, and user accounts. The admin panel is supposed to be accessible only to users with administrative privileges. However, due to misconfigured access controls, a standard user discovers they can access admin functions by simply modifying the URL or manipulating their session cookies.
Security flaw exploitation
-
Session Cookie Manipulation
A standard user, after logging in, manipulates their session cookie's privilege level from "user" to "admin" using a browser's developer tools or a proxy tool. -
Direct URL Access (Force Browsing)
The user directly navigates toshopexample.com/adminby typing the URL into the browser's address bar. Due to inadequate access control checks, the server renders the admin page, granting the user administrative rights without proper authentication. -
Unauthorized Actions
Leveraging this access, the user views sensitive information, modifies product listings, and even accesses other users' order details, all of which are unauthorized actions that compromise data integrity and privacy.
Solutions by FortiWeb
To prevent the described security issues of session cookie manipulation, direct URL access (force browsing), and unauthorized actions on an online shopping website using FortiWeb, you can follow a series of configuration steps and best practices.
-
Solution 1 - Configuring URL Access to restrict access to shopexample.com/admin
-
Solution 2 - Configuring User Tracking and Custom Policy to restrict access
Solution 1 - Configuring URL Access to restrict access to shopexample.com/admin
Access to administrative panels for your web application should only be allowed if the client’s source IP address is an administrator’s computer on your private management network.
Step 1 - Create an URL Access rule to allow access to "/admin" from the administrators' source IP addresses.
- Go to Web Protection > Access > URL Access.
- Select the URL Access Rule tab.
- Click Create New.
- Configure these settings:
Name Allow-admin-access Host Status Enable Host shopexample.com
Action Continue—The matching request will be allowed by URL access but be evaluated by any subsequent rules defined in the web protection profile.
Severity Medium
Trigger Action Select a trigger action to specify how FortiWeb will log the attack. - Click OK.
- Click Create New to add a new URL access condition entry to the set.
- Configure these settings:
Source Address Enable. Source Address Type IPv4/IPv6 / IP Range
IPv4/IPv6 / IP Range Enter the IP address or IP range of the administrator’s computer on your private management network.
URL Type Simple String URL Pattern /admin
Meet this condition if: Object matches the Source Address and the URL pattern. - Click OK.
Step 2 - Create another URL Access rule to block access to "/admin" from all source IPs
- Go to Web Protection > Access > URL Access.
- Select the URL Access Rule tab.
- Click Create New.
- Configure these settings:
Name Block-all-access Host Status Enable. Host shopexample.com
Action Alert & Deny—Block the request and generate an alert, log message, or both.
Severity Medium
Trigger Action Select a trigger action to specify how FortiWeb will log the attack. - Click OK.
- Click Create New to add a new URL access condition entry to the set.
- Configure these settings:
Source Address Disable URL Type Simple String URL Pattern /admin
Meet this condition if: Object matches the URL pattern and Parameters. - Click OK.
Step 3 - Create a URL Access policy to reference the two rules
- Go to Web Protection > Access > URL Access.
- Select the URL Access Policy tab.
- Click Create New.
- In Name, type a unique name that can be referenced by other parts of the configuration. The maximum length is 63 characters.
- Click OK.
- Click Create New to add the first rule to the set.
- From the Access Rule Name drop-down list, select "Allow-admin-access".
- Click OK.
- Click Create New to add the second rule to the set.
- From the Access Rule Name drop-down list, select "Block-all-access".
- Click OK.
Make sure the rule "Allow-admin-access" ranks higher (it's ID number is smaller) than the rule "Block-all-access". In this way, all the traffic to "/admin" will be blocked except the ones from the administrator’s source IPs because they will hit the first rule and be taken the action "Continue" specified in the first rule.
For more information, see Restricting access based on specific URLs.
Solution 2 - Configuring User Tracking and Custom Policy to restrict access
Implement user tracking and create a custom policy to block unauthorized access to the admin panel. This process involves setting rules for user tracking based on usernames, and then defining a custom policy to deny access to the /admin path if usernames are not included in the authorized list.
To track users by usernames:
- Go to Tracking > User Tracking, and select the User Tracking Rule tab.
- Click Create New, and then complete the following settings:
- Click OK.
- Go to Tracking > User Tracking, select the User Tracking Policy tab, click Create New, enter a name for the policy, and then click OK.
- Click Create New, select the user tracking rule you have created, and then click OK.
| Name | Enter a name that identifies the rule. |
| Authentication URL | Enter the login URL, /login.php |
| Username Field | The name of the field for users to enter their username, for example: Username. |
| Password Field | The name of the field for users to enter their password, for example: Password. |
| Session ID Name |
Type the name of the session ID that is used to identify each session. |
To block non-admin users from accessing shopexample.com/admin:
- Go to Web Protection > Advanced Protection > Custom Policy, and select the Custom Rule tab.
- Click Create New.
- Configure these settings:
-
Name Type a unique name that can be referenced in other parts of the configuration. The maximum length is 63 characters. Action Alert & Deny—Block the request (or reset the connection) and generate an alert email and/or log message.
Severity Medium
Trigger Action Select a trigger action to specify how FortiWeb will log the attack. - Click OK.
- Click Create New to add a User entry to the set.
- From Filter Type, select User.
- For User Name, enter the names of your admin users, for example: "admin" or "alice, alex, adam".
- For the Meet this condition if: option, select Object does not match the User Name.
- Click OK.
- Click Create New to add a URL entry to the set.
- From Filter Type, select URL.
- Enter
/adminin Regular Expression. - For the Meet this condition if: option, select URL matches the Regular Expression.
- Click OK.
- Go to Web Protection > Advanced Protection > Custom Policy, and select the Custom Policy tab.
- Click Create New.
- Select the custom rule you have created.
- Click OK.
For more information, see Tracking and Custom Policy.
Additional protection: Configuring Cookie Security to prevent cookie manipulation
To prevent users from manipulating their session cookies and thereby escalating their privileges from "user" to "admin", it's crucial to implement robust cookie security measures.
- Go to Web Protection > Cookie Security.
- Click Create New and configure these settings:
- Click OK.
For more information, see Cookie security.
Next step
Apply the security rules to web protection profile and then reference the profile in a server policy. See:
Make sure to enable Client Management in Policy > Web Protection Profile.
By implementing these comprehensive security measures, shopexample.com can mitigate the risks associated with session cookie manipulation and direct URL access to admin functions. These strategies will help maintain the integrity and privacy of user data and the overall security of the online platform.
It's also recommended to configure settings on your back-end servers to define user roles based on job functions and responsibilities within the organization, so that only authorized users can access specific back-end resources.