Broken access control, forged requests and API security

10 min 6 sections 5 practice questions 11 sources citedISC2 objective 8.5

A website or app has to answer two questions about every request: who is asking, and may this person do this particular thing. Many serious flaws come from answering only the first. Others trick a trusted browser or server into sending a request for an attacker. Programs that talk to other programs through an interface face the same flaws at far greater speed. No programming background is assumed.

By the end of this unit you will be able to:

  • Explain why a signed-in user can still reach records that are not theirs, and how the server prevents it
  • Tell apart cross-site request forgery and server-side request forgery by what is tricked
  • Explain how directory traversal and session fixation work and what stops each
  • Tell apart REST and SOAP, and an API key and an access token
  • Choose the controls that protect an application programming interface

Report number 2232

An illustrative example

A children's swimming club sends parents a link to each term's progress report. Parents sign in with an email address and a password. The report opens at a web address ending in report=2231.

One father notices the number and, out of curiosity, types 2232. He sees another child's report: her name, her level and a note about her epilepsy. He tries 2233 and gets a third. He emails the club secretary, who replies that this cannot happen, because every parent has to sign in.

Every parent did have to sign in. Which check was the club's website missing?

Signing in proves identity, not permission to see a record

Every request to a website should pass two checks. Authentication settles who is asking. settles whether this person may take this action on this particular record. The swimming club's site made the first check and skipped the second.

Broken access control is any flaw that lets a user act outside the permissions intended for them. It heads the , a widely used list of the most serious to web applications published by the Open Worldwide Application Security Project (OWASP).

Insecure direct object reference (IDOR)
The program fetches a record by an identifier the user can change, such as a number in the web address. It never checks that the record belongs to that user. This was the swimming club's flaw.
Force browsing
An attacker guesses the address of a staff page, which opens because it checked only that someone was signed in.
Privilege escalation
Gaining rights beyond those granted. Vertical escalation moves up, from customer to administrator. Horizontal escalation moves sideways into another user's account at the same level, as the father did.

The fix sits on the server and runs on every request. Access is denied by default and granted only by a rule. The program looks a record up through the signed-in user's own account, so a report that is not theirs cannot be found at all. Long random identifiers make guessing harder, but they are not a fix: a leaked link still opens.

Common misconception

“A page or record that nothing links to is safe, because nobody can find it.”

Addresses leak through browser history, forwarded emails and guessing. Only a permission check on the server protects a record.

Directory traversal: climbing out of the permitted folder

Files on a server sit in folders inside folders, like rooms off corridors. A request may name one file, such as menu.pdf, for the program to fetch from a public folder. In the notation servers use, two dots mean the folder one level up.

Directory traversal, also called path traversal or dot-dot-slash, puts that notation into the name: ../../config/passwords. A program that joins the typed name onto its folder climbs out of the public folder and hands over a file it was never meant to serve.

  • Do not build file paths from what users type. Give each permitted file a number and look the number up.
  • Where a name must be accepted, turn it into its simplest full form first, then check that it lies inside the permitted folder.
  • Accept only known good names. Stripping out ../ fails, because the same climb can be written in many .
  • Run the program with access only to the folders it needs, and keep configuration files outside the public folder.

Forged requests: CSRF tricks a browser, SSRF tricks a server

A browser sends a site's cookie, the small token that keeps a user signed in, with every request to that site, whatever page caused the request. Cross-site request forgery (CSRF) abuses that habit.

A forged payment

A customer is signed in to her bank in one browser tab. In another she reads a forum post that hides a form. The form sends the bank a request: pay 500 pounds to this account. Her browser attaches her bank cookie as usual, and the bank sees a proper request from a signed-in customer.

The defence is an anti-forgery token: a random value the site places in its own forms and checks on every request that changes something. A page on another site cannot read it, so cannot include it. Marking cookies SameSite, so the browser withholds them from requests other sites start, is a second layer. Cross-site scripting defeats both, because script inside the page can read the token.

Server-side request forgery (SSRF) tricks the server instead. Some features fetch a web address the user supplies, such as a picture to attach. The attacker supplies an address only the server can reach, such as a cloud provider's metadata service at 169.254.169.254, which can hand out access keys.

Blocking that one address fails. The same internal address can be written in other forms, such as hexadecimal, or reached through a domain name that points to it. The defences are an of permitted destinations, refusing redirects, and network rules that keep the server from internal services it does not need.

CSRF tricks a browser, SSRF tricks a server

CSRF tricks a browser, SSRF tricks a serverTwo panels. CSRF: an attacker's page makes the victim's browser send a request, with the bank cookie, to the bank; an anti-forgery token stops it. SSRF: the attacker's request makes the web server fetch from an internal service; an allow list stops it.CSRFthe browser is trickedAttacker'spagehides a formVictim'sbrowseradds the cookieBanksees a properrequestAnti-forgerytokenmissing hereSSRFthe server is trickedAttacker'srequestnames an addressWeb serverfetches it frominsideInternalservicecloud metadataAllow listof permitteddestinationsCSRF tricks a browser, SSRF tricks a serverTwo panels. CSRF: an attacker's page makes the victim's browser send a request, with the bank cookie, to the bank; an anti-forgery token stops it. SSRF: the attacker's request makes the web server fetch from an internal service; an allow list stops it.CSRFthe browser is trickedAttacker'spagehides a formVictim'sbrowseradds the cookieBanksees a properrequestAnti-forgerytokenmissing hereSSRFthe server is trickedAttacker'srequestnames an addressWeb serverfetches it frominsideInternalservicecloud metadataAllow listof permitteddestinations
Read this figure as text

Both attacks forge a request from a party the target trusts. Cross-site request forgery (CSRF) abuses the trust a site places in a signed-in user's browser. Server-side request forgery (SSRF) abuses the trust internal services place in the server.

  1. CSRF: a customer signed in to her bank reads a page on another site that hides a form. The form makes her browser send the bank a request, such as paying 500 pounds to an account.
  2. Her browser attaches her bank cookie, as it does with every request to the bank, so the bank sees a proper request from a signed-in customer.
  3. The defence is an anti-forgery token: a random value the bank places in its own forms and checks on every request that changes something. A page on another site cannot read it, so the forged request lacks it and is refused. SameSite cookies are a second layer.
  4. SSRF: some features fetch a web address the user supplies, such as a picture to attach. The attacker's request names an address only the server can reach.
  5. The server fetches from that internal service, such as a cloud provider's metadata service at 169.254.169.254, which can hand out access keys.
  6. The defence is an allow list of permitted destinations, with redirects refused and network rules that keep the server from internal services it does not need.
Three attacks that are easily confused
AttackWhat is trickedWhat the attacker gainsMain defence
Cross-site scripting (XSS)The victim's browser runs the attacker's script inside the trusted pageReads the page and acts as the user
Cross-site request forgery (CSRF)The victim's browser sends a request the user never meantOne action done as the user, without seeing the replyAnti-forgery tokens
Server-side request forgery (SSRF)The server fetches an address the attacker choseA way into the internal networkAllow list of destinations

A short test separates the first two. Cross-site scripting abuses the trust a user places in a site. Cross-site request forgery, also called XSRF or session riding, abuses the trust a site places in a signed-in user's browser.

Session flaws: a guessed, stolen or planted token

After sign-in, a site recognises the user by a session token carried in a cookie. Whoever holds the token is treated as the user, so code that handles it carelessly gives accounts away.

Predictable token
A token built from a counter or the time can be guessed. Tokens come from a secure random source, with at least 64 bits of randomness.
Session hijacking
An attacker obtains a valid token, by cross-site scripting, by reading unencrypted traffic or by guessing, and uses it as the user.
Session fixation
The attacker plants a token he already knows in the victim's browser before she signs in. If the site keeps that token after sign-in, he shares her session. The fix is a new token at sign-in and at every change of privilege.

A cookie carrying a token is marked Secure, so it travels only over connections, and HttpOnly, so scripts in the page cannot read it. Logging out ends the session on the server, not only in the browser.

APIs: REST and SOAP, keys and tokens

An application programming interface (API) is the fixed set of requests one program accepts from another. It has no screens for a person to notice anything odd, so every check is in code, and a caller can send thousands of requests a second.

Two styles are common. Representational state transfer (REST) gives each thing the API manages, such as an order, its own web address. Callers use the web's ordinary verbs to read, create, change and delete it, and the server keeps no memory between requests. SOAP is a protocol that wraps every message in a fixed XML envelope holding a header and a body.

API key
A long fixed string issued to a calling program and sent with each request. It identifies the program, for usage limits and billing. It does not identify a person, it is easily copied and it rarely expires.
Access token
A short-lived credential issued after authentication that states what its holder may do and until when. is the common framework for issuing one: the user approves access, and the application receives a token instead of the user's password.

The API checks a token's signature, issuer, intended audience and expiry on every call. A key alone says nothing about the user behind a call or which records that user may reach.

Controls that protect an API

The OWASP API Security Top 10 for 2023 opens with broken , its name for insecure direct object reference. It also lists server-side request forgery, unrestricted resource consumption and improper management.

  • Authorisation of every object and every function, on the server, for each call.
  • Encryption in transit: the API is offered only over HTTPS.
  • Schema validation: each request is checked against a written description of the fields, types and sizes allowed, and anything else is refused.
  • Minimal responses: only the fields the caller needs, never the whole record.
  • Rate limiting: each caller may make only so many requests in a period, which blocks mass guessing and stops one caller exhausting the service.
  • Inventory: a list of every live API, version and host, so old and test versions are retired instead of forgotten.

An API gateway is a single front door placed before many APIs. It can authenticate callers, apply rate limits and record every request in one place. It cannot know whether booking 88413 belongs to the caller, so object checks stay in the application.

For an API: authenticate the caller, authorise each object, validate each request, limit each caller, list each API.

A question, worked through

A theatre's mobile app calls an API to show a customer's bookings at an address ending /bookings/88412. A researcher reports that changing the number shows other customers' names and seat numbers. The API already requires an access token on every call. The security manager must choose one fix this week.

Which change BEST removes the cause?

  1. Check on the server that each booking belongs to the token's user
  2. Replace the booking numbers with long random identifiers
  3. Put an API gateway in front of the API to limit request rates
  4. Require an API key from the mobile app with every request
Decide on your answer, then open the reasoning
  1. A signed-in caller reached other people's records by changing a number. That is insecure direct object reference, a form of broken access control. The question asks for the fix that removes the cause.
  2. Rule out d. An API key identifies the calling app, which is already known. It says nothing about which bookings this user may see.
  3. Rule out c. Rate limiting slows a caller who tries thousands of numbers. One changed number still shows one stranger's booking.
  4. Between a and b: random identifiers make guessing harder and are a sound extra layer. A booking link that leaks in an email or a screenshot still opens for anyone who holds it.
  5. Only a server-side check that the booking belongs to the user behind the token removes the cause. Option a.

Answer: A. Check on the server that each booking belongs to the token's user

Choosing between good answers

A signed-in user changes a number in a request and sees someone else's record
the flaw is broken access control, by name insecure direct object reference. The answer is an authorisation check on the server for each object.
A hidden form on another site makes a signed-in user's browser change something on a trusted site
it is cross-site request forgery, answered by anti-forgery tokens. If the server itself is made to fetch an internal address, it is server-side request forgery, answered by an allow list of destinations.
An option relies on an API key alone to protect personal data
reject it. A key identifies a program, not a person, and grants no permission record by record.
One option puts a gateway in front of an API and another fixes its code
for a flaw about which records a user may reach, choose the fix in code. A gateway handles authentication, rate limits and logging.

Check your understanding

5 questions on this unit, easiest first. Confirm an answer to see the reasoning for it, then the right answer, the other options and the rule to reuse. Your answers are kept in this browser and feed readiness and review.

These questions are drafts that no named reviewer has approved yet.

Question 1 of 5

A customer of an online shop alters a request and reaches the screen that staff use to manage orders and refunds. Which flaw has the customer exploited?

What to remember

  • Authentication proves who is asking. Broken access control is the failure to check, on the server and for every request, what that person may do.
  • Insecure direct object reference returns a record by an identifier the user can change, without checking that the record is theirs.
  • Directory traversal uses ../ to climb out of the permitted folder. Permitted files are mapped to fixed identifiers instead of paths built from input.
  • Cross-site request forgery tricks the victim's browser and is stopped by anti-forgery tokens. Server-side request forgery tricks the server and is stopped by an allow list of destinations.
  • An API key identifies a program. An access token, often issued through OAuth 2.0, carries a user's permissions for a limited time.
  • API controls are object-level authorisation, encryption in transit, schema validation, minimal responses, rate limiting and an inventory of every API.

Say it from memory

  1. Name the controls that protect an API, and say what an API key does and does not prove.

    Server-side authorisation of every object and function, HTTPS only and schema validation of each request. Also minimal responses, rate limiting and an inventory of every API and version. A gateway in front can add authentication, limits and logging. An API key identifies the calling program. It does not identify the user or grant permission to any particular record.

    Read this part again

  2. What is an insecure direct object reference, and how does vertical privilege escalation differ from horizontal?

    The program fetches a record by an identifier the user can change, such as a number in the web address, and never checks that the record belongs to that user. Vertical escalation moves up, from customer to administrator. Horizontal escalation moves sideways into another user's account at the same level.

    Read this part again

  3. What is directory traversal, and why does stripping out ../ fail as a defence?

    Directory traversal, also called path traversal or dot-dot-slash, puts ../ into a requested file name so the program climbs out of the public folder. Stripping it fails because the same climb can be written in many encodings. Better: give each permitted file a number, or check the simplest full form of the path lies inside the permitted folder.

    Read this part again

  4. How does cross-site request forgery differ from server-side request forgery, and what is the main defence against each?

    CSRF tricks the victim's browser into sending a request the user never meant, abusing the trust a site places in a signed-in browser; the defence is anti-forgery tokens. SSRF tricks the server into fetching an address the attacker chose, giving a way into the internal network; the defence is an allow list of destinations.

    Read this part again

  5. What is session fixation, and how is a session cookie protected?

    The attacker plants a token he already knows in the victim's browser before she signs in, and shares her session if the site keeps it. The fix is a new token at sign-in and at every change of privilege. The cookie is marked Secure and HttpOnly, and logging out ends the session on the server.

    Read this part again

  6. How does REST differ from SOAP, and an API key from an access token?

    REST gives each managed thing its own web address, uses the web's ordinary verbs, and the server keeps no memory between requests. SOAP wraps every message in a fixed XML envelope with a header and a body. An API key is a long fixed string identifying a calling program. An access token is short-lived and states what its holder may do and until when.

    Read this part again

Sources

  • OWASP Top 10:2025, OWASPBroken access control as the first category, with insecure direct object references, force browsing and elevation of privilege among its forms, path traversal, CSRF and SSRF mapped to it, and deny by default with record ownership as prevention.
  • Insecure Direct Object Reference Prevention Cheat Sheet, OWASP FoundationInsecure direct object reference as access to records by a changed identifier, an access check for each object as the defence, and complex identifiers being defence in depth only.
  • Path Traversal, OWASP FoundationPath traversal, also called directory traversal or dot-dot-slash, the ../ example, and defences: known values instead of file names, normalising before use, accepting known good input, and restricting file access.
  • Cross-Site Request Forgery Prevention Cheat Sheet, OWASP FoundationCSRF as tricking an authenticated browser, the browser sending cookies automatically, synchroniser tokens, SameSite cookies as defence in depth, XSS defeating CSRF defences, and no state changes through GET.
  • Server Side Request Forgery Prevention Cheat Sheet, OWASP FoundationSSRF as abuse of an application to reach internal networks, the cloud metadata service at 169.254.169.254, allow lists of destinations, disabling redirects, network segmentation, and deny lists being easily bypassed, including by hex, octal and other encodings of an address and by domain names bound to internal addresses.
  • OWASP Cheat Sheet Series: Session Management, OWASP FoundationAt least 64 bits of entropy in session identifiers, session hijacking and fixation, renewing the identifier after sign-in and privilege change, the Secure and HttpOnly attributes, and ending the session on the server.
  • REST Security Cheat Sheet, OWASP FoundationREST as resources identified by addresses and stateless requests, HTTPS only, API keys not being sufficient protection for sensitive resources, rate limiting, and checking a token's signature, issuer, audience and expiry.
  • SOAP Version 1.2 Part 1: Messaging Framework (Second Edition), World Wide Web Consortium (W3C)SOAP as a protocol for exchanging structured information in XML, with an envelope holding an optional header and a body.
  • RFC 6749: The OAuth 2.0 Authorization Framework, IETFOAuth 2.0 issuing an access token to a client so that it need not hold the resource owner's credentials.
  • OWASP API Security Top 10 2023, OWASPThe 2023 API Security Top 10 opening with broken object level authorisation, and including unrestricted resource consumption, server-side request forgery and improper inventory management.
  • NIST SP 800-204: Security Strategies for Microservices-based Application Systems, NISTAPI gateways as a framework that bundles authentication and access management with throttling for many services.