Courses3 levels
Level 1 · Foundations11 courses
Level 2 · Core5 courses
Level 3 · Advanced5 courses
Labs8 topics
Library Practice exams AI Range Pricing Start free

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.

  • api-security
  • rest
  • soap
  • bola
  • mass-assignment
On this page 14 sections
  1. ·Why APIs Fail Differently
  2. ·Prerequisites
  3. ·Lab Setup
  4. ·Build the target
  5. 1Map the API Surface
  6. 2Authenticate and Read the Token
  7. Locked: Exploit BOLA to Read Another User's Order
  8. Locked: Exploit BFLA to Reach an Admin-Only Function
  9. Locked: Abuse Mass Assignment on a Profile Update
  10. Locked: Find Excessive Data Exposure
  11. Locked: Test Rate Limiting on a Sensitive Endpoint
  12. Locked: Enumerate and Abuse the Legacy SOAP Service
  13. Locked: Check Your Work
  14. 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

Recommended before or alongside this lab:

Lab Setup

  • Attack box: Kali Linux with curl, jq and ffuf installed (jq --version to check; install with sudo apt install jq if 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.

PartAddressRole
REST APIhttp://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 servicehttp://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) and role: customer.
  • Two customer accounts: alice (user_id 1001) and bob (user_id 1002), both with the password Lab-Pass1!. Use your own password. Neither account has admin rights.
  • GET /api/v1/admin and GET /api/v1/admin/users: present but undocumented, answers 403 with no token, and returns the user list (with each user's role) for any valid token regardless of role.
  • PATCH on a user's own profile: binds every key of the JSON body, including role, to the stored record (mass assignment).
  • The WSDL of the pricing service lists the operations GetPrice and ApplyDiscount, and ApplyDiscount needs 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

1

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"
done

Example output:

404 swagger.json
404 openapi.json
200 api/swagger.json
404 api/v1/swagger.json
404 v2/api-docs
curl -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 40

Example 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

2

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 -d

Example 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.

Related