The app is only the front of it
A shopping app on your phone draws buttons. Behind every button is a request to an API, a set of addresses a program can call. Anybody can call those addresses without the app, with any values they like.
So the API must defend itself. The OWASP API Security Top 10 lists the ten ways APIs most often fail. This lesson learns the list on a real API.
The one rule
Warning
Probe only your own lab copy, which has no way out to the internet. Testing anybody else's system needs their written permission first. In the UK, getting into a computer without permission is a crime under the Computer Misuse Act 1990.
Quick check: the rule
Have a go
Quick check: the rule
3 questionsBy the end of this lesson
Note
I can match a weakness in an API to its entry in the OWASP API Security Top 10.
Key words
| Word | What it means | Example |
|---|---|---|
| API | addresses a program calls to read or change data | |
| Endpoint | one address of an API | /api/Users |
| Object | one record an API returns | basket 6 |
| Property | one field of an object | role |
| Inventory | the list of every endpoint you run | |
| OWASP | a charity that publishes free security guidance |
The cells students fill in are left blank in this preview.
Starter
Have a go
Starter
4 questionsTen ways an API fails
The list is numbered API1 to API10, most serious first. Three of them are about authorisation: whose object is this, which properties may this caller set, and which functions may this caller use.
The others are about signing in, using too much, business flows, fetching addresses for a caller, settings, knowing what you run, and trusting other APIs.
The OWASP API Security Top 10, 2023
| Entry | Name | In one line |
|---|---|---|
| API1 | Broken object level authorisation | A caller reads or changes another user's object |
| API2 | Broken authentication | Signing in or tokens can be faked or guessed |
| API3 | Broken object property level authorisation | A caller sees or sets a field they should not |
| API4 | Unrestricted resource consumption | Nothing limits how much a caller asks for |
| API5 | Broken function level authorisation | A caller uses a function meant for another role |
| API6 | Unrestricted access to sensitive business flows | A flow such as buying is automated against the business |
| API7 | Server side request forgery | The API fetches an address the caller chose |
| API8 | Security misconfiguration | A setting or open file gives too much away |
| API9 | Improper inventory management | Endpoints run that nobody lists or looks after |
| API10 | Unsafe consumption of APIs | The API trusts what another API sends it |
The cells students fill in are left blank in this preview.
Check
Have a go
Check
3 questionsStart with what the API says it has
Juice Shop publishes a document for one part of its API at /api-docs. An attacker reads it, then tries the paths the shop's own pages call.
The first Run lists the paths the document names. The second calls the product search, which the shop's pages use but the document does not name.
The paths the API document names
curl -s http://juice-shop:3000/api-docs/swagger-ui-init.js | grep -o '"/[a-z]*": {'Shown here, not run. Press Start lab to type it into your own lab’s terminal.
An endpoint the document leaves out
curl -s -o /dev/null -w "%{http_code}\n" "http://juice-shop:3000/rest/products/search?q=apple"Shown here, not run. Press Start lab to type it into your own lab’s terminal.
Check
Have a go
Check
3 questionsA customer calls a list meant for staff
The shop's admin page lists every account. Its button is hidden from customers, but the endpoint behind it, /api/Users, only checks that you are signed in.
Make a customer account, sign in, and call the list with the customer's token. Then look for the shop's own access log, which should never be public.
Make a customer account
curl -s -H "Content-Type: application/json" -d '{"email":"[email protected]","password":"Ana_12345","passwordRepeat":"Ana_12345"}' http://juice-shop:3000/api/UsersShown here, not run. Press Start lab to type it into your own lab’s terminal.
Sign in and keep the reply
curl -s -H "Content-Type: application/json" -d '{"email":"[email protected]","password":"Ana_12345"}' -o ana.json http://juice-shop:3000/rest/user/loginShown here, not run. Press Start lab to type it into your own lab’s terminal.
Count the accounts a customer can list
curl -s -H "Authorization: Bearer $(grep -o 'eyJ[^"]*' ana.json)" http://juice-shop:3000/api/Users | grep -o '"email":"[^"]*"' | wc -lShown here, not run. Press Start lab to type it into your own lab’s terminal.
The server's log, open to anybody
curl -s http://juice-shop:3000/support/logs | grep -o 'access.log[0-9.-]*' | sort -uShown here, not run. Press Start lab to type it into your own lab’s terminal.
Worked example: naming what the Runs found
| What the Run showed | Entry | Why |
|---|---|---|
| The document names /orders only | API9 | Most endpoints are unlisted |
| A customer's token lists 24 accounts | API5 | A staff function with no role check |
| The account list carries each role | API3 | Fields a customer need not see |
| The access log is listed to anybody | API8 | A file that should never be served |
The cells students fill in are left blank in this preview.
A common mistake
Warning
Many people think an API is safe because the app never shows the dangerous button. The app is one caller among many. Any program can call any endpoint with any values. Every endpoint checks who is calling and what they may do, on the server, every time.
Match each finding to its entry
Have a go
Loading…
Your answers are marked here and are not kept. An account keeps your marks.
Try it: keep a list of findings
# Each finding from the Runs, and the entry it belongs to.
findings = {
"Any customer lists every account": "API5",
"The access log is open to anybody": "API8",
"Paths missing from the API document": "API9",
}
for finding, entry in findings.items():
print(entry, finding)
# Add a fourth: "A customer reads another basket". Which entry is it?
Make a free account to save your work and track your progress.
Fix it and watch for it
Fix: keep an inventory of every endpoint and retire the ones nobody owns. Check the role in the handler of every staff function. Return only the fields the caller needs. Serve no logs or backups.
Detect: compare the paths in your access log with your inventory each week. Alert when a customer account calls a staff endpoint, which a role check would also refuse.
Assignment: find the unlisted endpoints
An access log line looks like 10.0.0.5 - - [21/Nov/2026:13:34:37 +0000] "GET /api/Users/3 HTTP/1.1" 200 412 "-" "curl/8.14.1". Write three functions.
parse_line(line) returns (method, path, status): the method and path from the quoted request, without any ? part, and the status as a whole number. endpoint(method, path) returns "METHOD /path" with every part of the path that is all digits replaced by {id}, so GET /api/Users/3 becomes "GET /api/Users/{id}". unlisted(lines, documented) returns the sorted list of endpoints seen in the lines that are not in the set documented, each once.
def parse_line(line):
return ("", "", 0)
def endpoint(method, path):
return method + " " + path
def unlisted(lines, documented):
return []
Make a free account to save your work and track your progress.
Exit quiz
Have a go