Practice library / Web attacks
Lab · Medium · 2 hoursFree account
API & Web Service Attacks
BOLA, BFLA, mass assignment, data exposure and legacy SOAP abuse against one API target.
On this page 14 sections
- ·Why APIs Fail Differently
- ·Prerequisites
- ·Lab Setup
- ·Build the target
- 1Map the API Surface
- 2Authenticate and Read the Token
- Locked: Exploit BOLA to Read Another User's Order
- Locked: Exploit BFLA to Reach an Admin-Only Function
- Locked: Abuse Mass Assignment on a Profile Update
- Locked: Find Excessive Data Exposure
- Locked: Test Rate Limiting on a Sensitive Endpoint
- Locked: Enumerate and Abuse the Legacy SOAP Service
- Locked: Check Your Work
- Locked: Clean Up and Next Lab
An API skips the browser. A field a form hides, a button only one role sees, a body the UI never sends — all of it can still reach the server. Flaws appear when a check the UI was meant to enforce never ran on the server too. Attack a REST target for BOLA, BFLA, mass assignment, excessive data exposure and missing rate limits, then enumerate a legacy SOAP service for an operation that asks for no identity at all.
What You'll Learn
- Map an undocumented REST API's endpoints from its schema and by fuzzing
- Exploit Broken Object Level Authorization (BOLA) to read another user's data
- Exploit Broken Function Level Authorization (BFLA) to reach an admin-only function
- Abuse mass assignment to escalate your own privileges through a profile update
- Spot excessive data exposure and missing rate limiting in API responses
- Enumerate a legacy SOAP service from its WSDL and call an undocumented operation
Why APIs Fail Differently
A REST or SOAP API skips the browser. There is no form to limit what you can send. There is no hidden field the UI quietly protects, and no page that only shows a button to the right role. Every check the server would normally get "for free" from the UI has to be enforced again, explicitly, on the server. The UI can hide a field or a button; the API cannot. APIs fail when that re-enforcement is skipped, not when the attack technique is exotic. Every step in this lab is the same idea you already used in Insecure Direct Object References (IDOR): the server trusts an identifier or a field without checking it. This lab applies that idea across a JSON REST API and a legacy SOAP service.
Prerequisites
- Insecure Direct Object References (IDOR) — required. BOLA in Step 3 is IDOR applied to a JSON API instead of a URL parameter. Do this lab first if IDOR is new to you.
Recommended before or alongside this lab:
- Attacking Authentication Mechanisms — weak API authentication feeds directly into the BFLA test in Step 4.
- Broken Authentication & Sessions — the token handling this lab's Step 2 reads and reuses.
- Web Fuzzing & Directory Brute Forcing — the enumeration technique used in Step 1.
- NoSQL Injection — many REST APIs sit on a NoSQL store; injection there often starts from the same JSON bodies you tamper with here.
- Insecure Deserialization — some APIs accept serialized objects instead of JSON; mass assignment in Step 5 is the JSON-era version of the same trust problem.
- HTTP Misconfiguration Abuse — CORS and header misconfigurations on an API amplify every technique in this lab.
- Server-Side Request Forgery & Attacks — an API that fetches a URL on your behalf (a webhook, an import) combines SSRF with the authorization bugs here.
- Modern Web Exploitation — broader context for where API attacks fit in a modern web engagement.
- WordPress Exploitation — the WordPress REST API (
/wp-json/) is a real-world example of every flaw class this lab teaches. - JavaScript Deobfuscation — useful when a single-page app's minified JS is the only documentation for an undocumented endpoint.
- White-Box Web Exploitation: Auth Bypass to RCE — the source-level view of the same authorization bugs you test here black-box.
- Bug Bounty Hunting — APIs are a top target in bounty programs; read this for the hunting methodology around what you practise here.
Lab Setup
- Attack box: Kali Linux with
curl,jqandffufinstalled (jq --versionto check; install withsudo apt install jqif missing).
Build the target
KaliRange hosts no targets, no virtual machines and no lab files. You run this lab on your own machine, against an API, ShopAPI, that you build. The address 10.0.6.40 below is the example address of this lab. Replace it with the address of your own application.
| Part | Address | Role |
|---|---|---|
| REST API | http://10.0.6.40:8081/api/v1/ | Order-management service for a demo storefront. Publishes an OpenAPI/Swagger document that lists five paths and no admin path |
| Legacy SOAP pricing service | http://10.0.6.40:8082/pricing (WSDL at ?wsdl) | Bolted on years earlier and never re-reviewed when the REST layer was added |
- A customer JSON Web Token carries
sub(a small sequential user ID) androle: customer. - Two customer accounts:
alice(user_id1001) andbob(user_id1002), both with the passwordLab-Pass1!. Use your own password. Neither account has admin rights. GET /api/v1/adminandGET /api/v1/admin/users: present but undocumented, answers403with no token, and returns the user list (with each user'srole) for any valid token regardless of role.PATCHon a user's own profile: binds every key of the JSON body, includingrole, to the stored record (mass assignment).- The WSDL of the pricing service lists the operations
GetPriceandApplyDiscount, andApplyDiscountneeds no authentication.
Build such an API yourself: a small REST service and a small SOAP service with exactly these flaws. Run both in containers or virtual machines on your own computer, and note their state before Step 1 so that you can go back.
Authorized-lab only. Run every command in this lab only against 10.0.6.40, your own application.
Do not point any of these requests at an API you do not own or do not have written authorisation to test — unauthorised access to a computer system is a criminal offence in most countries.
Step 1: Map the API Surface
Find the schema, then fuzz for what the schema leaves out
Start with the API's own documentation. A REST API often publishes an OpenAPI/Swagger document at a predictable path; check the common ones before you fuzz anything.
for p in swagger.json openapi.json api/swagger.json api/v1/swagger.json v2/api-docs; do
curl -s -o /dev/null -w "%{http_code} $p\n" "http://10.0.6.40:8081/$p"
doneExample output:
404 swagger.json
404 openapi.json
200 api/swagger.json
404 api/v1/swagger.json
404 v2/api-docscurl -s http://10.0.6.40:8081/api/swagger.json | jq '.paths | keys'Example output:
[
"/api/v1/login",
"/api/v1/orders",
"/api/v1/orders/{id}",
"/api/v1/users/{id}",
"/api/v1/users/{id}/profile"
]The published schema lists five paths and no admin path. Fuzz past the documentation to find what
it leaves out:
ffuf -u http://10.0.6.40:8081/api/v1/FUZZ \
-w /usr/share/seclists/Discovery/Web-Content/directory-list-2.3-medium.txt \
-mc 200,201,301,302,401,403 -t 40Example output (shortened):
orders [Status: 401, Size: 42]
users [Status: 401, Size: 42]
admin [Status: 403, Size: 51]
health [Status: 200, Size: 15]Why it matters. admin never appeared in swagger.json, but it exists and answers 403
(forbidden, not 404 Not Found) even with no token at all. An endpoint missing from the published
schema is not a secret endpoint — it is only undocumented. Step 4 tests whether 403 really means
"blocked for everyone" or only "blocked for an unauthenticated request."
Step 2: Authenticate and Read the Token
Log in, then decode what the token tells you about the ID scheme
Log in as alice and keep her token for every later step. A JWT's payload is base64, not encrypted,
so you can read it without knowing the signing key.
curl -s -X POST http://10.0.6.40:8081/api/v1/login \
-H 'Content-Type: application/json' \
-d '{"username":"alice","password":"Lab-Pass1!"}' | jq .Example output:
{
"token": "eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOjEwMDEsInJvbGUiOiJjdXN0b21lciJ9.REDACTED",
"user_id": 1001
}echo "eyJzdWIiOjEwMDEsInJvbGUiOiJjdXN0b21lciJ9" | base64 -dExample output:
{"sub":1001,"role":"customer"}export ALICE_TOKEN="eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOjEwMDEsInJvbGUiOiJjdXN0b21lciJ9.REDACTED"Why it matters. The token's payload tells you two things before you send a single attack request:
object IDs are small sequential integers (sub: 1001), and authorization is meant to run on a role
string. Neither fact needs the signing key — this lab only reads the payload to plan the next steps.
Attacking the signature itself (algorithm confusion, a weak or leaked key) is covered in
OAuth & JWT Attacks, not here.
Sign in to continue
8 more sections are for signed-in members. It is free: sign in with Google.