Easier to read with cream paper, a tint, more contrast or larger text? Choose your colours and text, once, for every page.

Free lesson

The OWASP API Security Top 10

After this lesson: I can match a weakness in an API to its entry in the OWASP API Security Top 10.

55 min lesson6 commandsOWASP Juice Shop lab: a vulnerable web shop to attack in your own copy

A quick check that you are not a bot, then your own lab opens on the interactive lesson.

Already have an account? Sign in

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 questions
Have a go: your answers are marked here and then forgotten. Sign in if you would like your score kept, and to pick up where you left off.Sign in to keep your score

By 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

WordWhat it meansExample
APIaddresses a program calls to read or change data
Endpointone address of an API/api/Users
Objectone record an API returnsbasket 6
Propertyone field of an objectrole
Inventorythe list of every endpoint you run
OWASPa charity that publishes free security guidance

The cells students fill in are left blank in this preview.

Starter

Have a go

Starter

4 questions
Have a go: your answers are marked here and then forgotten. Sign in if you would like your score kept, and to pick up where you left off.Sign in to keep your score

Ten 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

EntryNameIn one line
API1Broken object level authorisationA caller reads or changes another user's object
API2Broken authenticationSigning in or tokens can be faked or guessed
API3Broken object property level authorisationA caller sees or sets a field they should not
API4Unrestricted resource consumptionNothing limits how much a caller asks for
API5Broken function level authorisationA caller uses a function meant for another role
API6Unrestricted access to sensitive business flowsA flow such as buying is automated against the business
API7Server side request forgeryThe API fetches an address the caller chose
API8Security misconfigurationA setting or open file gives too much away
API9Improper inventory managementEndpoints run that nobody lists or looks after
API10Unsafe consumption of APIsThe API trusts what another API sends it

The cells students fill in are left blank in this preview.

Check

Have a go

Check

3 questions
Have a go: your answers are marked here and then forgotten. Sign in if you would like your score kept, and to pick up where you left off.Sign in to keep your score

Start 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

Command
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

Command
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 questions
Have a go: your answers are marked here and then forgotten. Sign in if you would like your score kept, and to pick up where you left off.Sign in to keep your score

A 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

Command
curl -s -H "Content-Type: application/json" -d '{"email":"[email protected]","password":"Ana_12345","passwordRepeat":"Ana_12345"}' http://juice-shop:3000/api/Users

Shown here, not run. Press Start lab to type it into your own lab’s terminal.

Sign in and keep the reply

Command
curl -s -H "Content-Type: application/json" -d '{"email":"[email protected]","password":"Ana_12345"}' -o ana.json http://juice-shop:3000/rest/user/login

Shown here, not run. Press Start lab to type it into your own lab’s terminal.

Count the accounts a customer can list

Command
curl -s -H "Authorization: Bearer $(grep -o 'eyJ[^"]*' ana.json)" http://juice-shop:3000/api/Users | grep -o '"email":"[^"]*"' | wc -l

Shown here, not run. Press Start lab to type it into your own lab’s terminal.

The server's log, open to anybody

Command
curl -s http://juice-shop:3000/support/logs | grep -o 'access.log[0-9.-]*' | sort -u

Shown 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 showedEntryWhy
The document names /orders onlyAPI9Most endpoints are unlisted
A customer's token lists 24 accountsAPI5A staff function with no role check
The account list carries each roleAPI3Fields a customer need not see
The access log is listed to anybodyAPI8A 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

Code: python
# 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.

Code: python
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

Exit quiz

5 questions
Have a go: your answers are marked here and then forgotten. Sign in if you would like your score kept, and to pick up where you left off.Sign in to keep your score

Teaching a class? Set this module for your students with a teacher guide, marked assignments and a lab for every student.