Ajoute 16 skills de sécurité (sélection web/API)
Tirés de mukul975/anthropic-cybersecurity-skills (commit 54a7988, Apache-2.0) : contrôle d'accès/IDOR, en-têtes et CSP, CORS, OAuth, JWT, XSS, fonctions serverless, rate limiting, paquets npm, gitleaks, RGPD, OWASP API Top 10. Les 800 autres (offensifs, Windows/AD, forensique…) sont laissés de côté. Voir .claude/skills/README.md. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01YVo1qxKoBQCaMd7Ue8PGbe
This commit is contained in:
74 files changed
+14803
No files matched your search
@@ -0,0 +1,201 @@
|
||||
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to the Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by the Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding any notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. Please do not remove or change
|
||||
the license header comment from a contributed file except when
|
||||
necessary.
|
||||
|
||||
Copyright 2026 mukul975
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
@@ -0,0 +1,369 @@
|
||||
---
|
||||
name: testing-for-broken-access-control
|
||||
description: Systematically tests web applications and APIs for broken access control
|
||||
(OWASP A01:2021), including privilege escalation, missing function-level checks, insecure
|
||||
direct object references, and multi-tenant data leakage, using Burp Suite with the
|
||||
Authorize extension. Use during authorized penetration tests or RBAC/multi-tenant
|
||||
authorization audits.
|
||||
domain: cybersecurity
|
||||
subdomain: web-application-security
|
||||
tags:
|
||||
- penetration-testing
|
||||
- access-control
|
||||
- authorization
|
||||
- owasp
|
||||
- privilege-escalation
|
||||
- web-security
|
||||
version: '1.0'
|
||||
author: mahipal
|
||||
license: Apache-2.0
|
||||
nist_csf:
|
||||
- PR.PS-01
|
||||
- ID.RA-01
|
||||
- PR.DS-10
|
||||
- DE.CM-01
|
||||
mitre_attack:
|
||||
- T1190
|
||||
- T1059.007
|
||||
- T1505.003
|
||||
- T1083
|
||||
- T1068
|
||||
---
|
||||
|
||||
# Testing for Broken Access Control
|
||||
|
||||
## When to Use
|
||||
|
||||
- During authorized penetration tests as the primary assessment for OWASP A01:2021 - Broken Access Control
|
||||
- When evaluating role-based access control (RBAC) implementations across all application endpoints
|
||||
- For testing multi-tenant applications where users in one organization should not access another's data
|
||||
- When assessing API endpoints for missing or inconsistent authorization checks
|
||||
- During security audits where privilege escalation and unauthorized access are primary concerns
|
||||
|
||||
## Prerequisites
|
||||
|
||||
- **Authorization**: Written penetration testing agreement for the target
|
||||
- **Burp Suite Professional**: With Authorize extension for automated access control testing
|
||||
- **Multiple test accounts**: Accounts at each role level (admin, manager, user, guest)
|
||||
- **Application role matrix**: Documentation of what each role should and should not access
|
||||
- **curl/httpie**: For manual endpoint testing with different authentication contexts
|
||||
- **ffuf**: For discovering hidden endpoints that may lack access controls
|
||||
|
||||
## Workflow
|
||||
|
||||
### Step 1: Map All Endpoints and Create Access Control Matrix
|
||||
|
||||
Document every endpoint and the expected access level for each role.
|
||||
|
||||
```bash
|
||||
# Extract all endpoints from Burp Site Map
|
||||
# Target > Site Map > Right-click > Copy URLs in this host
|
||||
|
||||
# Build a matrix of endpoints vs roles:
|
||||
# | Endpoint | Admin | Manager | User | Guest |
|
||||
# |-----------------------|-------|---------|------|-------|
|
||||
# | GET /admin/dashboard | Allow | Deny | Deny | Deny |
|
||||
# | GET /api/users | Allow | Allow | Deny | Deny |
|
||||
# | PUT /api/users/{id} | Allow | Deny | Own | Deny |
|
||||
# | DELETE /api/posts/{id} | Allow | Allow | Own | Deny |
|
||||
|
||||
# Discover hidden endpoints
|
||||
ffuf -u "https://target.example.com/FUZZ" \
|
||||
-w /usr/share/seclists/Discovery/Web-Content/raft-medium-directories.txt \
|
||||
-mc 200,301,302,403 -fc 404 \
|
||||
-H "Authorization: Bearer $USER_TOKEN" \
|
||||
-o endpoints.json -of json
|
||||
|
||||
# API endpoint discovery
|
||||
ffuf -u "https://target.example.com/api/v1/FUZZ" \
|
||||
-w /usr/share/seclists/Discovery/Web-Content/api/api-endpoints.txt \
|
||||
-mc 200,201,204,301,302,401,403,405 -fc 404 \
|
||||
-H "Authorization: Bearer $USER_TOKEN"
|
||||
```
|
||||
|
||||
### Step 2: Configure Automated Access Control Testing
|
||||
|
||||
Set up Burp Authorize extension for parallel role-based testing.
|
||||
|
||||
```
|
||||
# Install Authorize extension:
|
||||
# Burp > Extender > BApp Store > Search "Authorize" > Install
|
||||
|
||||
# Configuration for three-tier testing:
|
||||
# 1. Browse the application as Admin (capture all requests)
|
||||
# 2. In Authorize tab:
|
||||
# a. Add Regular User's session token in "Replace cookies/headers"
|
||||
# b. Optionally add a second row for Unauthenticated (no auth header)
|
||||
|
||||
# Example header replacement setup:
|
||||
# Row 1 (Low-privilege user):
|
||||
# Cookie: session=low_priv_user_session
|
||||
# Authorization: Bearer low_priv_token
|
||||
#
|
||||
# Row 2 (Unauthenticated):
|
||||
# [Empty - removes all auth headers]
|
||||
|
||||
# Enable interception in Authorize:
|
||||
# - Check "Intercept requests from Proxy"
|
||||
# - Check "Intercept requests from Repeater"
|
||||
|
||||
# Authorize shows results as:
|
||||
# Green = Properly restricted (different response for different user)
|
||||
# Red = POTENTIALLY VULNERABLE (same response regardless of role)
|
||||
# Orange = Uncertain (needs manual verification)
|
||||
```
|
||||
|
||||
### Step 3: Test Vertical Privilege Escalation
|
||||
|
||||
Attempt to access higher-privilege functionality with lower-privilege accounts.
|
||||
|
||||
```bash
|
||||
# Collect tokens for each role
|
||||
ADMIN_TOKEN="Bearer admin_jwt_here"
|
||||
MANAGER_TOKEN="Bearer manager_jwt_here"
|
||||
USER_TOKEN="Bearer user_jwt_here"
|
||||
|
||||
# Test admin endpoints with user token
|
||||
ADMIN_ENDPOINTS=(
|
||||
"GET /admin/dashboard"
|
||||
"GET /admin/users"
|
||||
"POST /admin/users/create"
|
||||
"PUT /admin/settings"
|
||||
"DELETE /admin/users/5"
|
||||
"GET /admin/logs"
|
||||
"GET /admin/reports/export"
|
||||
"POST /admin/backup"
|
||||
)
|
||||
|
||||
for entry in "${ADMIN_ENDPOINTS[@]}"; do
|
||||
method=$(echo "$entry" | cut -d' ' -f1)
|
||||
endpoint=$(echo "$entry" | cut -d' ' -f2)
|
||||
echo -n "$method $endpoint (as user): "
|
||||
status=$(curl -s -o /dev/null -w "%{http_code}" \
|
||||
-X "$method" \
|
||||
-H "Authorization: $USER_TOKEN" \
|
||||
-H "Content-Type: application/json" \
|
||||
"https://target.example.com$endpoint")
|
||||
if [ "$status" == "200" ] || [ "$status" == "201" ]; then
|
||||
echo "VULNERABLE ($status)"
|
||||
else
|
||||
echo "OK ($status)"
|
||||
fi
|
||||
done
|
||||
|
||||
# Test with method override headers
|
||||
curl -s -o /dev/null -w "%{http_code}" \
|
||||
-X POST \
|
||||
-H "Authorization: $USER_TOKEN" \
|
||||
-H "X-HTTP-Method-Override: DELETE" \
|
||||
"https://target.example.com/admin/users/5"
|
||||
|
||||
# Test with different HTTP methods
|
||||
for method in GET POST PUT PATCH DELETE OPTIONS HEAD; do
|
||||
echo -n "$method /admin/users: "
|
||||
curl -s -o /dev/null -w "%{http_code}" \
|
||||
-X "$method" \
|
||||
-H "Authorization: $USER_TOKEN" \
|
||||
"https://target.example.com/admin/users"
|
||||
echo
|
||||
done
|
||||
```
|
||||
|
||||
### Step 4: Test Horizontal Privilege Escalation
|
||||
|
||||
Verify that users cannot access resources belonging to other users at the same privilege level.
|
||||
|
||||
```bash
|
||||
# User A (ID: 101) testing access to User B's (ID: 102) resources
|
||||
USER_A_TOKEN="Bearer user_a_jwt"
|
||||
|
||||
RESOURCES=(
|
||||
"/api/users/102/profile"
|
||||
"/api/users/102/orders"
|
||||
"/api/users/102/messages"
|
||||
"/api/users/102/documents"
|
||||
"/api/users/102/settings"
|
||||
"/api/users/102/payment-methods"
|
||||
)
|
||||
|
||||
for resource in "${RESOURCES[@]}"; do
|
||||
echo -n "GET $resource: "
|
||||
response=$(curl -s -w "\n%{http_code}" \
|
||||
-H "Authorization: $USER_A_TOKEN" \
|
||||
"https://target.example.com$resource")
|
||||
status=$(echo "$response" | tail -1)
|
||||
body_len=$(echo "$response" | head -n -1 | wc -c)
|
||||
if [ "$status" == "200" ] && [ "$body_len" -gt 50 ]; then
|
||||
echo "VULNERABLE ($status, $body_len bytes)"
|
||||
else
|
||||
echo "OK ($status)"
|
||||
fi
|
||||
done
|
||||
|
||||
# Test write operations across users
|
||||
curl -s -X PUT \
|
||||
-H "Authorization: $USER_A_TOKEN" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{"name":"Hacked","email":"hacked@evil.com"}' \
|
||||
"https://target.example.com/api/users/102/profile" -w "%{http_code}"
|
||||
|
||||
# Test delete operations
|
||||
curl -s -X DELETE \
|
||||
-H "Authorization: $USER_A_TOKEN" \
|
||||
"https://target.example.com/api/users/102/documents/1" -w "%{http_code}"
|
||||
```
|
||||
|
||||
### Step 5: Test Function-Level Access Control
|
||||
|
||||
Verify that specific functions enforce authorization properly.
|
||||
|
||||
```bash
|
||||
# Test unauthenticated access to protected endpoints
|
||||
PROTECTED_ENDPOINTS=(
|
||||
"/api/user/profile"
|
||||
"/api/transactions"
|
||||
"/api/settings"
|
||||
"/admin/dashboard"
|
||||
"/api/export/users"
|
||||
)
|
||||
|
||||
for endpoint in "${PROTECTED_ENDPOINTS[@]}"; do
|
||||
echo -n "No auth: GET $endpoint: "
|
||||
curl -s -o /dev/null -w "%{http_code}" \
|
||||
"https://target.example.com$endpoint"
|
||||
echo
|
||||
done
|
||||
|
||||
# Test with expired/invalid tokens
|
||||
curl -s -o /dev/null -w "%{http_code}" \
|
||||
-H "Authorization: Bearer invalid_token_here" \
|
||||
"https://target.example.com/api/user/profile"
|
||||
|
||||
# Test role manipulation in JWT claims
|
||||
# If JWT contains role claim, try modifying it
|
||||
# (requires JWT vulnerability - see JWT testing skill)
|
||||
|
||||
# Test parameter-based role escalation
|
||||
curl -s -X PUT \
|
||||
-H "Authorization: $USER_TOKEN" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{"role":"admin","is_admin":true,"permissions":["admin","superuser"]}' \
|
||||
"https://target.example.com/api/users/101/profile"
|
||||
|
||||
# Test registration with elevated role
|
||||
curl -s -X POST \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{"email":"new@test.com","password":"Test123!","role":"admin"}' \
|
||||
"https://target.example.com/api/auth/register"
|
||||
```
|
||||
|
||||
### Step 6: Test Multi-Tenant Isolation
|
||||
|
||||
Verify that tenant boundaries are enforced in multi-tenant applications.
|
||||
|
||||
```bash
|
||||
# User in Tenant A testing access to Tenant B's resources
|
||||
TENANT_A_TOKEN="Bearer tenant_a_user_jwt"
|
||||
|
||||
# Direct tenant resource access
|
||||
curl -s -H "Authorization: $TENANT_A_TOKEN" \
|
||||
"https://target.example.com/api/organizations/tenant-b-id/users" | jq .
|
||||
|
||||
curl -s -H "Authorization: $TENANT_A_TOKEN" \
|
||||
"https://target.example.com/api/organizations/tenant-b-id/settings" | jq .
|
||||
|
||||
# Test tenant switching via header
|
||||
curl -s -H "Authorization: $TENANT_A_TOKEN" \
|
||||
-H "X-Tenant-ID: tenant-b-id" \
|
||||
"https://target.example.com/api/users" | jq .
|
||||
|
||||
# Test tenant ID in request body
|
||||
curl -s -X POST \
|
||||
-H "Authorization: $TENANT_A_TOKEN" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{"tenant_id":"tenant-b-id","query":"SELECT * FROM users"}' \
|
||||
"https://target.example.com/api/reports/custom"
|
||||
|
||||
# Enumerate tenant IDs
|
||||
ffuf -u "https://target.example.com/api/organizations/FUZZ" \
|
||||
-w <(seq 1 100) \
|
||||
-H "Authorization: $TENANT_A_TOKEN" \
|
||||
-mc 200 -t 10 -rate 20
|
||||
```
|
||||
|
||||
## Key Concepts
|
||||
|
||||
| Concept | Description |
|
||||
|---------|-------------|
|
||||
| **Vertical Privilege Escalation** | Lower-privilege user accessing higher-privilege functionality (user -> admin) |
|
||||
| **Horizontal Privilege Escalation** | User accessing another user's resources at the same privilege level |
|
||||
| **Function-Level Access Control** | Authorization checks on specific features/functions regardless of URL |
|
||||
| **RBAC** | Role-Based Access Control - permissions assigned to roles, roles assigned to users |
|
||||
| **ABAC** | Attribute-Based Access Control - permissions based on user/resource/environment attributes |
|
||||
| **Multi-Tenant Isolation** | Ensuring data and functionality separation between different organizations/tenants |
|
||||
| **Insecure Direct Object Reference** | Accessing objects by manipulating identifiers without authorization checks |
|
||||
| **Missing Function-Level Check** | Endpoint exists but does not verify the caller has permission to invoke it |
|
||||
|
||||
## Tools & Systems
|
||||
|
||||
| Tool | Purpose |
|
||||
|------|---------|
|
||||
| **Burp Suite Professional** | Request interception and role-based testing |
|
||||
| **Authorize (Burp Extension)** | Automated access control testing across sessions |
|
||||
| **AutoRepeater (Burp Extension)** | Automatically replays requests with different auth contexts |
|
||||
| **Postman** | API testing with environment switching between roles |
|
||||
| **ffuf** | Discovering hidden endpoints that may lack access controls |
|
||||
| **OWASP ZAP** | Access control testing with context-aware scanning |
|
||||
|
||||
## Common Scenarios
|
||||
|
||||
### Scenario 1: Admin Panel Without Auth Check
|
||||
The `/admin/dashboard` endpoint returns the admin panel when accessed with a regular user's session token. The front-end hides the admin menu, but the back-end does not enforce role checks.
|
||||
|
||||
### Scenario 2: API Endpoint Missing Authorization
|
||||
The `DELETE /api/users/{id}` endpoint checks for authentication (valid token) but not authorization (admin role). Any authenticated user can delete any other user's account.
|
||||
|
||||
### Scenario 3: Tenant Data Leakage
|
||||
A SaaS application uses `tenant_id` in API request headers. Changing the `X-Tenant-ID` header to another tenant's ID returns their data, bypassing tenant isolation.
|
||||
|
||||
### Scenario 4: Mass Assignment Role Escalation
|
||||
The user profile update endpoint at `PUT /api/users/{id}` accepts a `role` field in the JSON body. Submitting `"role":"admin"` alongside a profile update elevates the user to administrator.
|
||||
|
||||
## Output Format
|
||||
|
||||
```
|
||||
## Broken Access Control Assessment Report
|
||||
|
||||
**Target**: target.example.com
|
||||
**Assessment Date**: 2024-01-15
|
||||
**OWASP Category**: A01:2021 - Broken Access Control
|
||||
|
||||
### Access Control Matrix Results
|
||||
| Endpoint | Admin | Manager | User | Guest | Expected | Actual |
|
||||
|----------|-------|---------|------|-------|----------|--------|
|
||||
| GET /admin/dashboard | 200 | 200 | 200 | 302 | Admin only | FAIL |
|
||||
| DELETE /api/users/{id} | 200 | 200 | 200 | 401 | Admin only | FAIL |
|
||||
| GET /api/users/other/profile | 200 | 200 | 200 | 401 | Own only | FAIL |
|
||||
| PUT /api/users/other/settings | 200 | 200 | 200 | 401 | Own only | FAIL |
|
||||
| GET /api/org/other-tenant | 200 | 200 | 200 | 401 | Same tenant | FAIL |
|
||||
|
||||
### Critical Findings
|
||||
1. **Vertical Escalation**: Regular users can access /admin/* endpoints
|
||||
2. **Horizontal IDOR**: Users can read/modify other users' profiles
|
||||
3. **Tenant Isolation**: Cross-tenant data access via header manipulation
|
||||
4. **Mass Assignment**: Role escalation via profile update endpoint
|
||||
|
||||
### Impact
|
||||
- Complete administrative access for any authenticated user
|
||||
- Full user data access across all accounts (15,000+ users)
|
||||
- Cross-tenant data breach affecting 200+ organizations
|
||||
- Account takeover via profile modification
|
||||
|
||||
### Recommendation
|
||||
1. Implement server-side authorization checks on every endpoint
|
||||
2. Use a centralized authorization middleware/framework
|
||||
3. Enforce object-level authorization (verify ownership before access)
|
||||
4. Validate tenant context server-side, never from client headers
|
||||
5. Use allowlists for mass assignment (only permit expected fields)
|
||||
6. Implement audit logging for all access control decisions
|
||||
```
|
||||
@@ -0,0 +1,60 @@
|
||||
# API Reference: Testing for Broken Access Control
|
||||
|
||||
## requests Library
|
||||
|
||||
### Authentication Patterns
|
||||
```python
|
||||
# Bearer token authentication
|
||||
headers = {"Authorization": "Bearer <token>", "Content-Type": "application/json"}
|
||||
|
||||
# Cookie-based authentication
|
||||
cookies = {"session": "session_value"}
|
||||
|
||||
# Multiple methods
|
||||
resp = requests.request("DELETE", url, headers=headers)
|
||||
```
|
||||
|
||||
## Test Categories
|
||||
|
||||
### Vertical Privilege Escalation
|
||||
Test admin endpoints with regular user credentials:
|
||||
```python
|
||||
for endpoint in admin_endpoints:
|
||||
resp = requests.get(url, headers=user_headers)
|
||||
# 200 = VULNERABLE, 403 = properly restricted
|
||||
```
|
||||
|
||||
### Horizontal Privilege Escalation (IDOR)
|
||||
Access other users' resources:
|
||||
```python
|
||||
# Replace {id} with other user's ID
|
||||
resp = requests.get(f"/api/users/{other_id}/profile", headers=user_headers)
|
||||
```
|
||||
|
||||
### HTTP Method Override
|
||||
```python
|
||||
override_headers = ["X-HTTP-Method-Override", "X-Method-Override", "X-HTTP-Method"]
|
||||
```
|
||||
|
||||
### Mass Assignment Fields
|
||||
| Field | Description |
|
||||
|-------|-------------|
|
||||
| `role` | User role (admin, user) |
|
||||
| `is_admin` | Boolean admin flag |
|
||||
| `permissions` | Permission array |
|
||||
| `access_level` | Numeric access level |
|
||||
| `user_type` | User type classification |
|
||||
|
||||
## Response Status Interpretation
|
||||
| Status | Meaning |
|
||||
|--------|---------|
|
||||
| 200/201 | Access granted (potential vulnerability if unexpected) |
|
||||
| 401 | Not authenticated |
|
||||
| 403 | Authenticated but not authorized (correct behavior) |
|
||||
| 404 | Resource not found (may hide from unauthorized users) |
|
||||
| 405 | Method not allowed |
|
||||
|
||||
## OWASP References
|
||||
- A01:2021 Broken Access Control: https://owasp.org/Top10/A01_2021-Broken_Access_Control/
|
||||
- WSTG Access Control: https://owasp.org/www-project-web-security-testing-guide/latest/4-Web_Application_Security_Testing/05-Authorization_Testing/
|
||||
- IDOR Testing: https://owasp.org/www-project-web-security-testing-guide/latest/4-Web_Application_Security_Testing/05-Authorization_Testing/04-Testing_for_Insecure_Direct_Object_References
|
||||
@@ -0,0 +1,195 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Agent for testing broken access control vulnerabilities during authorized assessments."""
|
||||
|
||||
import requests
|
||||
import json
|
||||
import argparse
|
||||
import urllib3
|
||||
from datetime import datetime
|
||||
from urllib.parse import urljoin
|
||||
|
||||
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
|
||||
|
||||
|
||||
def test_vertical_escalation(base_url, user_token, admin_endpoints):
|
||||
"""Test if a regular user can access admin endpoints."""
|
||||
print("\n[*] Testing vertical privilege escalation...")
|
||||
findings = []
|
||||
headers = {"Authorization": f"Bearer {user_token}", "Content-Type": "application/json"}
|
||||
methods = ["GET", "POST", "PUT", "DELETE"]
|
||||
for endpoint in admin_endpoints:
|
||||
for method in methods:
|
||||
url = urljoin(base_url, endpoint)
|
||||
try:
|
||||
resp = requests.request(method, url, headers=headers, timeout=10, verify=False)
|
||||
if resp.status_code in (200, 201, 204):
|
||||
findings.append({
|
||||
"type": "VERTICAL_ESCALATION", "method": method,
|
||||
"url": url, "status": resp.status_code, "severity": "CRITICAL",
|
||||
})
|
||||
print(f" [!] VULNERABLE: {method} {endpoint} -> {resp.status_code}")
|
||||
except requests.RequestException:
|
||||
continue
|
||||
print(f"[*] {len(findings)} vertical escalation findings")
|
||||
return findings
|
||||
|
||||
|
||||
def test_horizontal_escalation(base_url, user_token, resource_templates, other_user_ids):
|
||||
"""Test if a user can access another user's resources."""
|
||||
print("\n[*] Testing horizontal privilege escalation (IDOR)...")
|
||||
findings = []
|
||||
headers = {"Authorization": f"Bearer {user_token}", "Content-Type": "application/json"}
|
||||
for template in resource_templates:
|
||||
for uid in other_user_ids:
|
||||
url = urljoin(base_url, template.replace("{id}", str(uid)))
|
||||
try:
|
||||
resp = requests.get(url, headers=headers, timeout=10, verify=False)
|
||||
if resp.status_code == 200 and len(resp.text) > 50:
|
||||
findings.append({
|
||||
"type": "HORIZONTAL_ESCALATION", "url": url,
|
||||
"user_id": uid, "status": resp.status_code,
|
||||
"body_length": len(resp.text), "severity": "CRITICAL",
|
||||
})
|
||||
print(f" [!] IDOR: GET {url} -> {resp.status_code} ({len(resp.text)} bytes)")
|
||||
except requests.RequestException:
|
||||
continue
|
||||
print(f"[*] {len(findings)} horizontal escalation findings")
|
||||
return findings
|
||||
|
||||
|
||||
def test_method_override(base_url, user_token, endpoint):
|
||||
"""Test HTTP method override headers for access control bypass."""
|
||||
print(f"\n[*] Testing method override on {endpoint}...")
|
||||
findings = []
|
||||
url = urljoin(base_url, endpoint)
|
||||
headers = {"Authorization": f"Bearer {user_token}", "Content-Type": "application/json"}
|
||||
override_headers = ["X-HTTP-Method-Override", "X-Method-Override", "X-HTTP-Method"]
|
||||
for oh in override_headers:
|
||||
for method in ["DELETE", "PUT", "PATCH"]:
|
||||
test_headers = {**headers, oh: method}
|
||||
try:
|
||||
resp = requests.post(url, headers=test_headers, timeout=10, verify=False)
|
||||
if resp.status_code in (200, 201, 204):
|
||||
findings.append({
|
||||
"type": "METHOD_OVERRIDE_BYPASS", "url": url,
|
||||
"override_header": oh, "method": method,
|
||||
"status": resp.status_code, "severity": "HIGH",
|
||||
})
|
||||
print(f" [!] {oh}: {method} -> {resp.status_code}")
|
||||
except requests.RequestException:
|
||||
continue
|
||||
return findings
|
||||
|
||||
|
||||
def test_unauthenticated_access(base_url, protected_endpoints):
|
||||
"""Test if protected endpoints are accessible without authentication."""
|
||||
print("\n[*] Testing unauthenticated access...")
|
||||
findings = []
|
||||
for endpoint in protected_endpoints:
|
||||
url = urljoin(base_url, endpoint)
|
||||
try:
|
||||
resp = requests.get(url, timeout=10, verify=False)
|
||||
if resp.status_code == 200 and len(resp.text) > 50:
|
||||
findings.append({
|
||||
"type": "UNAUTHENTICATED_ACCESS", "url": url,
|
||||
"status": resp.status_code, "severity": "CRITICAL",
|
||||
})
|
||||
print(f" [!] OPEN: GET {endpoint} -> {resp.status_code}")
|
||||
except requests.RequestException:
|
||||
continue
|
||||
print(f"[*] {len(findings)} unauthenticated access findings")
|
||||
return findings
|
||||
|
||||
|
||||
def test_mass_assignment(base_url, user_token, profile_endpoint):
|
||||
"""Test if role/privilege fields can be modified via profile update."""
|
||||
print(f"\n[*] Testing mass assignment on {profile_endpoint}...")
|
||||
findings = []
|
||||
url = urljoin(base_url, profile_endpoint)
|
||||
headers = {"Authorization": f"Bearer {user_token}", "Content-Type": "application/json"}
|
||||
payloads = [
|
||||
{"role": "admin"}, {"is_admin": True}, {"permissions": ["admin", "superuser"]},
|
||||
{"user_type": "administrator"}, {"access_level": 99},
|
||||
]
|
||||
for payload in payloads:
|
||||
try:
|
||||
resp = requests.put(url, headers=headers, json=payload, timeout=10, verify=False)
|
||||
if resp.status_code in (200, 201):
|
||||
field = list(payload.keys())[0]
|
||||
resp_text = resp.text.lower()
|
||||
if str(payload[field]).lower() in resp_text:
|
||||
findings.append({
|
||||
"type": "MASS_ASSIGNMENT", "url": url,
|
||||
"field": field, "value": payload[field], "severity": "CRITICAL",
|
||||
})
|
||||
print(f" [!] VULNERABLE: {field}={payload[field]} accepted")
|
||||
except requests.RequestException:
|
||||
continue
|
||||
return findings
|
||||
|
||||
|
||||
def test_tenant_isolation(base_url, tenant_a_token, tenant_b_resources):
|
||||
"""Test cross-tenant data access."""
|
||||
print("\n[*] Testing tenant isolation...")
|
||||
findings = []
|
||||
headers = {"Authorization": f"Bearer {tenant_a_token}", "Content-Type": "application/json"}
|
||||
for resource in tenant_b_resources:
|
||||
url = urljoin(base_url, resource)
|
||||
try:
|
||||
resp = requests.get(url, headers=headers, timeout=10, verify=False)
|
||||
if resp.status_code == 200 and len(resp.text) > 50:
|
||||
findings.append({
|
||||
"type": "TENANT_ISOLATION_BREACH", "url": url,
|
||||
"status": resp.status_code, "severity": "CRITICAL",
|
||||
})
|
||||
print(f" [!] CROSS-TENANT: {url} -> {resp.status_code}")
|
||||
except requests.RequestException:
|
||||
continue
|
||||
return findings
|
||||
|
||||
|
||||
def generate_report(findings, output_path):
|
||||
"""Generate access control assessment report."""
|
||||
report = {
|
||||
"assessment_date": datetime.now().isoformat(),
|
||||
"total_findings": len(findings),
|
||||
"by_type": {},
|
||||
"by_severity": {},
|
||||
"findings": findings,
|
||||
}
|
||||
for f in findings:
|
||||
t = f.get("type", "UNKNOWN")
|
||||
s = f.get("severity", "INFO")
|
||||
report["by_type"][t] = report["by_type"].get(t, 0) + 1
|
||||
report["by_severity"][s] = report["by_severity"].get(s, 0) + 1
|
||||
with open(output_path, "w") as fh:
|
||||
json.dump(report, fh, indent=2)
|
||||
print(f"\n[*] Report: {output_path} | Findings: {len(findings)}")
|
||||
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(description="Broken Access Control Testing Agent")
|
||||
parser.add_argument("base_url", help="Base URL of the target")
|
||||
parser.add_argument("--user-token", help="Regular user's Bearer token")
|
||||
parser.add_argument("--admin-endpoints", nargs="+",
|
||||
default=["/admin/dashboard", "/admin/users", "/api/admin/settings"])
|
||||
parser.add_argument("--resource-templates", nargs="+",
|
||||
default=["/api/users/{id}/profile", "/api/users/{id}/orders"])
|
||||
parser.add_argument("--other-ids", nargs="+", default=["2", "3", "100", "101"])
|
||||
parser.add_argument("-o", "--output", default="access_control_report.json")
|
||||
args = parser.parse_args()
|
||||
|
||||
print(f"[*] Broken Access Control Assessment: {args.base_url}")
|
||||
findings = []
|
||||
findings.extend(test_unauthenticated_access(args.base_url, args.admin_endpoints))
|
||||
if args.user_token:
|
||||
findings.extend(test_vertical_escalation(args.base_url, args.user_token, args.admin_endpoints))
|
||||
findings.extend(test_horizontal_escalation(args.base_url, args.user_token,
|
||||
args.resource_templates, args.other_ids))
|
||||
findings.extend(test_method_override(args.base_url, args.user_token, args.admin_endpoints[0]))
|
||||
findings.extend(test_mass_assignment(args.base_url, args.user_token, "/api/users/me"))
|
||||
generate_report(findings, args.output)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Reference in new issue
Block a user