The main access and authentication risks in the OWASP API Top 10 (2023) are BOLA (API1), Broken Authentication (API2) and BFLA (API5). BOLA (IDOR) means the server does not check that the requested object belongs to the user, and BFLA means an ordinary role calls a function meant for a higher role. API3 (BOPLA) covers individual fields. Authorization is needed in every handler, and testing it takes two users.
API · Security
A user changed 42 to 43 in the URL and saw someone else's account. Does your test suite catch it?
The test "get my account" is green: the token is valid, the status is 200. But the same token sent to GET /accounts/43 returns another person's account. Authentication works, but nothing checks whose object it is. No test with only one user can find this. This lesson covers which risks of the OWASP API Security Top 10 concern access and authentication, and how a QA engineer checks them without playing a pentester.
How it is built
The OWASP API Security Top 10 (2023 edition) contains three risks about "who are you" and "what may you do":
API1 BOLA (Broken Object Level Authorization, IDOR in older terms): the server does not check whether the object with the given id belongs to the user.
API2 Broken Authentication: weak login, tokens that are never invalidated, sensitive operations without re-confirmation.
API5 BFLA (Broken Function Level Authorization): a regular user calls a function meant for a role with higher rights.
All three have one cause: authentication and authorization happen in different places. Authentication says "the token is genuine, this is user A", and a gateway or middleware usually does it. Authorization asks "may A read this particular object and call this particular function", and the answer depends on data in the database, so a gateway cannot do it. Every handler has to perform it or explicitly call a shared policy, and this is where it gets forgotten.
Where the ownership check lives
Figure 1. Step 1 is done by a gateway, step 2 must be done by every handler. The BOLA bug lives in step 2, which is highlighted because it is the one most often forgotten.
Why it is so. The server cannot "guess" that 43 is someone else's: an id is only a key in the database. So reliable protection means either an owner filter in the database query (WHERE id = 43 AND owner_id = :userId) or an explicit policy check. Hiding other people's ids (replacing sequential numbers with UUIDs) makes guessing harder but does not remove the bug: a UUID can be seen in an email, a log or someone's link, and the missing check is still missing.
Example: from one user to two
Before: one user in the tests, and nobody ever reaches into someone else's resource. The bug shows only when you check what happens with another person's token:
GET /v1/accounts/43 HTTP/1.1
Authorization: Bearer <token of the owner of account 42>
HTTP/1.1 200 OK
Content-Type: application/json
{ "id": 43, "owner": "Petro", "iban": "UA21...", "balance": 18200.50 }
After: two users, A and B. We request A's resource with B's token and check all methods, not just GET:
// tokenA belongs to user A (owner of account 42), tokenB to user Bconstas = (token: string) => ({ Authorization: 'Bearer ' + token });
test('user B cannot touch account 42 with any method', async ({ request }) => {
const url = '/v1/accounts/42';
const calls = [
request.get(url, { headers: as(tokenB) }),
request.patch(url, { headers: as(tokenB), data: { nickname: 'x' } }),
request.delete(url, { headers: as(tokenB) }),
request.get(url + '/transactions', { headers: as(tokenB) }),
];
for (const res ofawaitPromise.all(calls)) {
expect([403, 404]).toContain(res.status());
}
// the owner still sees an untouched accountconst own = await request.get(url, { headers: as(tokenA) });
expect(own.status()).toBe(200);
expect((await own.json()).nickname).not.toBe('x');
});
The test accepts 403 or 404: a product may choose either, see the lesson on information leaks. The final GET by the owner checks the main thing: even when the server answered 403, the change must not have gone through. That way the test also catches the bug "answered 403 but had already done it". The same rule applies to nested resources (/transactions) and to ids in the request body, not only in the path.
BFLA is checked similarly but with a different question: not "whose object is it" but "does the role have the right to the function at all":
test('a regular user cannot call admin functions', async ({ request }) => {
const res = await request.delete('/v1/admin/users/5', {
headers: { Authorization: 'Bearer ' + userToken },
});
expect(res.status()).toBe(403);
// and the target user must still existconst check = await request.get('/v1/admin/users/5', {
headers: { Authorization: 'Bearer ' + adminToken },
});
expect(check.status()).toBe(200);
});
The typical cause of the bug: the frontend hides the "Delete user" button for a regular role, while the endpoint trusts that the button is not visible. Hiding in the UI is not protection.
Broken Authentication: what to check
Password guessing: after several wrong attempts the answer is 429 or a lockout (details in the lesson on rate limiting).
Token invalidation: after logout and after a password change, the old token (or refresh token) stops working.
No token in the URL: a query ends up in logs and browser history.
Sensitive actions (changing password, email, IBAN) require the current password or a second factor.
Login responses do not differ for an existing and a non-existing account.
Limits and alternatives
A two-token test finds a missing check but does not prove the check exists in every handler. So the set is repeated for every new endpoint that accepts an id.
Manual BOLA checks automate well: from an OpenAPI specification you can generate a loop "for every endpoint with a path parameter try someone else's token". Tools such as ZAP or Burp help, but they do not know business logic (whose object it is).
This is only the top of the list. The full Top 10 also includes SSRF, misconfiguration, API inventory and safe consumption of third-party APIs. A pentest and code review cover what a tester cannot see from outside.
Common mistakes
One test user. Without a second token BOLA cannot be tested at all.
Checking only GET. Someone else's object can often be changed or deleted while reading is protected.
Treating a UUID instead of a number as protection. It only makes guessing harder.
Checking the role only in the UI. The button is gone, but the endpoint answers 200.
Not checking the state after a 403. The response may be right while the side effect has already happened.
Check yourself
A test sends user B's token to DELETE /accounts/42 (A's account) and gets 403. What is the test still missing?
Answer
A check that account A still exists. A 403 is only what the server says: if the check was done after the deletion, the account is already gone. So after a negative call the resource is read by its owner.
In the application the "Delete user" button is not shown to a regular user. Is that enough protection?
Answer
No. The interface only hides the call, while the server accepts any request with a valid token. Call DELETE /admin/users/5 directly with a regular user's token and expect 403.
Related lessons: “Excessive data, mass assignment, injections, rate limiting”, “Access and authorization: BOLA/IDOR, tokens, mass assignment”, “JWT and testing tokens”.
In an interview.Junior: The most important thing in API security is BOLA, or IDOR: with one user's token I request another user's resource and expect 403 or 404. I check it for all methods, and also admin functions under a regular role. Middle/Senior: Authentication says who you are, while authorization depends on data and has to be in every handler, so two test users are a must. After a negative call I read the resource as its owner to be sure there was no side effect. I also check token invalidation after logout and a password change, the login attempt limit, and sensitive actions without re-confirmation.
Excessive data, mass assignment, injections, rate limiting
A server exposes excessive data when it serializes a model as is, and accepts forbidden fields (mass assignment) when it binds a request body onto a model. Tests read the raw JSON, not the screen, and recheck state with a separate GET, since 200 does not prove a field was ignored. Injections must not give 500, and a rate limit gives 429 with Retry-After.
API · Security
PATCH of a profile got an extra role: admin field and it was saved. How do you find it before production?
The UI shows a name and an email, and the profile looks tidy. But the raw JSON response contains passwordHash and internalRiskScore, and PATCH /users/me with an extra field "role": "admin" makes the user an admin. None of it is visible on screen, so a manual check through the browser misses it. This lesson covers the risks where the server returns or accepts more than intended, plus the checks for injections and limits.
How it is built
In the 2023 edition of the OWASP API Security Top 10, "excessive data" and mass assignment are merged into API3 Broken Object Property Level Authorization: access to the object is allowed, but the server does not distinguish which of its fields may be read and changed. Next to it stand API4 Unrestricted Resource Consumption (no limits) and injections as a class of input validation errors. They share one cause: the server works with the whole object instead of describing explicitly what belongs to the contract.
Excessive data exposure. The handler fetches a model from the database and serializes it as is, counting on the frontend to show only what is needed. This is what arrives on the network:
Mass assignment. The framework automatically copies the fields of the request body onto the model. If the model has a role field, the client can send it:
The whole object versus an explicit list of fields
Typical
The model directly
The response returns every field of the model, the request writes every field of the body. Each new database field automatically becomes part of the API, including internal ones.
Better
Explicit DTOs or schemas
A separate list of fields for the response and for writing. An unknown field is ignored or gives 400. A new database field does not reach the API until it is added deliberately.
Figure 1. Both problems have one source: the API contract equals the database structure. The fix is also one: describe the contract separately.
Why it is so. Serializing a model "as is" and binding a body onto a model save code, so they are on by default. The price is deferred: every field added to the model later becomes readable and writable without any security decision.
Example: what to check and how
1. Excessive data. I read the raw JSON, not the screen, and compare the list of fields with the contract. The simplest way is a schema with additionalProperties: false: then every new field breaks the test and forces a decision. Separately I search by name: password, hash, token, secret, a full card number.
2. Mass assignment. I send fields the client must not be able to change and check with GET that they did not change:
test('PATCH /users/me ignores fields the client must not set', async ({ request }) => {
const before = await (await request.get('/v1/users/me')).json();
const res = await request.patch('/v1/users/me', {
data: { name: 'Ivan', role: 'admin', isVerified: true, balance: 1000000 },
});
expect([200, 400, 422]).toContain(res.status());
const after = await (await request.get('/v1/users/me')).json();
expect(after.role).toBe(before.role);
expect(after.isVerified).toBe(before.isVerified);
expect(after.balance).toBe(before.balance);
});
Three answers are acceptable: 200 with the field ignored, 400 or 422. One thing is not: the value changed. Checking the status is not enough, because 200 does not say whether the field was saved, so the test reads the state after the request.
3. Injections. SQL, NoSQL or command injection through parameters. For QA a basic set is enough: quotes, boolean conditions, special characters, NoSQL operators and very long strings in fields and query:
const payloads = ["'", "' OR 1=1--", '"; DROP TABLE users;--', '{"$ne": null}', 'A'.repeat(100000)];
for (const p of payloads) {
test('search survives payload ' + p.slice(0, 12), async ({ request }) => {
const res = await request.get('/v1/users', { params: { q: p } });
expect(res.status()).toBeLessThan(500);
const text = await res.text();
expect(text).not.toMatch(/SQL|syntax error|stack|Exception/i);
});
}
Expected: 4xx or a correct result (for a search it is just "nothing found"), no 500 and no SQL fragments in the body. It is a quick check for obvious errors, not a replacement for a pentest: parameterized queries in the code are only found by a code review.
4. Rate limiting. Without limits an API can be flooded, and four-digit SMS codes can be brute-forced. I check that after the threshold comes 429 with Retry-After:
test('login is rate limited per account', async ({ request }) => {
const statuses: number[] = [];
for (let i = 0; i < 20; i++) {
const res = await request.post('/v1/login', {
data: { email: 'user@example.test', password: 'wrong-' + i },
});
statuses.push(res.status());
}
expect(statuses).toContain(429);
const limited = await request.post('/v1/login', {
data: { email: 'user@example.test', password: 'wrong-x' },
});
expect(limited.headers()['retry-after']).toBeTruthy();
});
Limits and alternatives
A limit may apply per IP, per account or per API key, and these are different risks: an IP-only limit is bypassed by a distributed attack, an account-only limit does not stop guessing across many accounts with one password. Check both dimensions if they are declared.
In a limit test it is important not to lock the test account for other tests. Use a separate user and clear the lock after the run.
Page and file size are resources too: limit=100000 or uploading 2 GB must not take the service down. Expected: a cap on the maximum (page of 100 instead of 100000) or 400/413.
For injections, tools (ZAP, sqlmap) find more than a manual set, but they are noisy and create data. Run them on a test environment, not on production.
Common mistakes
Looking at the response in the UI. An extra field is not visible on screen but is in the JSON.
Checking only the status after mass assignment. 200 does not mean the field was ignored, so the state is read with a separate GET.
Accepting any response to an injection. A 500 with a DBMS error is a defect and a leak at once.
Testing a limit with one request. A limit triggers on a series, so check the sequence and the Retry-After header.
Bringing production down with load for the sake of "checking the limit". These tests run on a separate environment.
Check yourself
PATCH /users/me with "role": "admin" returns 200 and the body shows "role": "user". Is it a bug?
Answer
Probably not: the server ignored the field, which is an acceptable reaction. But the response could have been built from the input, so check with a separate GET /users/me and, if possible, by behaviour (whether admin functions are available).
For a search ?q=%27 (a quote) the server returns 500 with a stack trace. Which two problems are here?
Answer
First: unhandled input leads to an internal error, so validation or query parameterization is missing. Second: the body reveals internal details (a class, a query, a file path). Correct: 200 with an empty result or 400, an error without internal details.
Related lessons: “OWASP API Top 10: access and authentication”, “Security and fintech”, “429, 503, Retry-After and the circuit breaker”.
In an interview.Junior: I look at the raw JSON for extra sensitive fields, try mass assignment by adding role or balance to the body, and basic injections in string fields. I also check rate limiting: after the limit there must be a 429. Middle/Senior: The cause of the first two is that the contract equals the model structure, so I look for explicit response and write schemas with additionalProperties: false. After mass assignment I read the state with a separate GET instead of trusting the status. For limits I check IP, account, page size and that the response contains Retry-After.
JWT traps
A typical JWT (JWS) is signed but not encrypted: the signature guarantees integrity, while anyone can read the payload. The server must first verify the signature with its own algorithm and key, then the claims exp, iss and aud, and only then trust role. The traps are alg: none, algorithm confusion, a weak HS256 secret, unchecked claims and a stateless token that stays valid until exp even after logout.
API · Security
A token with alg: none and an empty signature got into the API. Which other JWT traps should you check?
A tester changes "role": "user" to "admin" in the payload, keeps the old signature, and the API answers 200. Or sets "alg": "none" in the header, removes the signature, and the server accepts the token. This is not exotic: they are error classes described in RFC 8725 (JWT Best Current Practices). The lesson covers the JWT weaknesses asked about at middle and senior level, and how to check them without special tools.
How it is built
A JWT (RFC 7519) has three base64url parts separated by dots. The signature covers the header and the payload:
The signature guarantees integrity, not secrecy. The payload is only encoded and anyone can read it without a key. The server has to do three things in this order: verify the signature with its own expected algorithm and key, check the claims (exp, nbf, iss, aud), and only then trust sub and role. All the traps appear when one of these steps is skipped or done in another order.
What the server must check, and what breaks
Figure 1. Each step protects against its own class of attacks (after the arrow: what happens if it is skipped). The payload content can be trusted only after all the previous ones.
Example: seven traps and how to check each
Algorithm none. The attacker sets "alg": "none" in the header and removes the signature. A server that trusts the alg field from the token will accept it. Expected: 401.
Algorithm confusion. A server with an asymmetric key (RS256) has a public key, which is not a secret. If the library takes the algorithm from the header, the attacker signs the token with HS256 using the public key as a symmetric secret. Correct: the server hard-codes the expected algorithm.
A weak HS256 secret. A short secret is brute-forced offline from a dictionary, after which any payload can be signed. A QA check: the secret must not be secret or the project name, and its length meets the algorithm's requirements (at least 256 bits for HS256).
Sensitive data in the payload. An email, a phone or an account number is visible to anyone who has the token.
exp, aud, iss are not checked. A token from another service or environment (stage on dev, a token for another API) must not be accepted.
Revocation. A JWT is stateless, so after logout or blocking a user the access token lives until exp. Protection: a short access token lifetime, refresh token rotation and a denylist for critical cases.
Trusting the kid and jku headers. If the server takes the key from a URL or a path in the header, an attacker can plant their own. This is harder to check from the QA side, but the question "where does the server get the key from" is worth asking.
To check alg none and the payload edit, a few functions are enough: they decode a token and build a forged one (a token without re-signing):
A 200 on "edited payload" would mean the server does not verify the signature at all and only reads the claims. A 500 is also a defect: the server is not ready for corrupted input.
Limits and alternatives
A signed token can be read. If the payload needs confidential data, use JWE (an encrypted token) or an opaque token with the data read on the server by key.
Opaque (reference) tokens are revoked instantly because the server checks them in a store, but every request needs a trip there. A JWT is cheaper per request but harder to revoke. It is a trade-off, not a "right" choice.
Algorithm confusion and kid are hard to reproduce without knowing the server's library. Here QA rather asks the developers ("which library, is the algorithm pinned") and reads the configuration than attacks blindly.
Tools (jwt.io for reading, jwt_tool or Burp extensions for forgeries) speed up the check. A production token is never pasted into an online decoder: it could be valid.
Common mistakes
Checking only an expired and a corrupted token. These are the simplest cases, while alg: none and a foreign aud go unnoticed.
Assuming the payload is "encrypted". It is encoded, and everyone can read it.
Relying on logout as revocation. After logout the JWT is still valid until exp unless there is a denylist.
Testing only a token of the same environment. It is a stage token accepted on dev that shows iss and aud are not checked.
Check yourself
A test changes "role": "user" to "admin" in the token, leaves the signature unchanged, and the API answers 401. Is that enough to consider signature verification correct?
Answer
It is a good sign but not proof. Also check alg: none and a token signed with a different key: the server could have rejected it because of the signature mismatch while still accepting a token without a signature.
A user was blocked, and his access token with exp in 15 minutes is still valid. What is wrong and what would you suggest?
Answer
A JWT is stateless and the server does not consult a store, so blocking has no effect until exp. Options: a shorter token lifetime and refresh token rotation, a user status check on sensitive operations, or a denylist for critical cases. It is a compromise between speed and controllability.
Related lessons: “JWT and testing tokens”, “OAuth 2.0 and OpenID Connect: roles, flows and what to test”, “Authorisation types in Postman”.
In an interview.Junior: Besides an expired and a corrupted token I check alg: none, a token from another environment and sensitive data in the payload. Middle/Senior: A correct server sets the algorithm and the key itself, then checks exp, iss, aud, and only then trusts role. A signature gives integrity but not secrecy. I also ask how the team revokes tokens: a JWT is stateless, so after logout it lives until exp, and the answer depends on the acceptable risk: a short access token, refresh token rotation or a denylist.
Information leaks: errors, URLs, logs and enumeration
An information leak in an API is excess visibility. Typical places: stack traces and SQL in errors, different responses for exists and does not exist, secrets in URLs and logs, forgotten versions. QA provokes errors and compares responses for an existing and a missing id or email by status, body and timing. Diagnostics stay in logs by request id. Choosing 404 over 403 depends on the product.
API · Security
Someone else's id gives 403, a non-existent one gives 404. What does this reveal to an attacker?
Much of the damage comes not from broken access but from information the API gives away between the lines. An error message with a class name and an SQL query, different responses for "exists" and "does not exist", a token in a query string, a password in logs. None of these opens data by itself, but each makes the next step easier. This lesson covers where an API gives away too much and how QA finds these places systematically.
How it is built
Information leaks belong to the class of "excess visibility": information useful for diagnostics is visible to those it was not meant for. In the OWASP API Top 10 2023 these are mostly API8 Security Misconfiguration (verbose errors, extra headers, open service endpoints) and API9 Improper Inventory Management (forgotten versions and documentation). Enumeration of accounts and resources sits next to them: it is not a separate item of the list but a consequence of different responses to different situations.
Why it is so. For a developer an error with a trace is convenient: you see what broke. Different responses for "not found" and "forbidden" are convenient for a client: it understands what to do. Both principles are normally right, and the problem is that at the trust boundary (a public API) they have to be limited deliberately. Diagnostics move to logs under a request id, and the client gets a general response.
Example: five places to look
1. Error messages. I provoke errors: broken JSON, a very long value, the ' character, an invalid id. I look at the body and the headers. Here is a response with defects:
HTTP/1.1 500 Internal Server Error
Content-Type: application/json
Server: Apache-Coyote/1.1
X-Powered-By: Servlet/4.0 JSP/2.3
{ "error": "org.postgresql.util.PSQLException: ERROR: invalid input syntax
for type integer: \"abc\"", "trace": "at com.shop.UserRepo.find(UserRepo.java:88)" }
There are three leaks: the exception class and the DBMS text, a stack trace with a file name, and in the headers the framework version (Server, X-Powered-By). A correct response is general, and the details live in logs under X-Request-Id:
HTTP/1.1 400 Bad Request
Content-Type: application/problem+json
X-Request-Id: 5b0e7c2a
{ "type": "https://api.shop.test/errors/validation",
"title": "Invalid request", "status": 400,
"detail": "id must be a number" }
An automated check looks for these signs in all error responses:
Exception class, SQL, file path, server version. An attacker learns which DBMS you have and where the weak spot is.
Better
A response for the client
A short description, a stable code and a request id. The rest lives in logs, and only the team has access to it.
Figure 1. The same error source, a different visibility. The request id links the response to the log.
2. Enumeration. If the response differs for "exists" and "does not exist", it is extra information:
403 for someone else's /invoices/1002 and 404 for a non-existent /invoices/999999 show which ids exist in the system. When the product requires hiding other people's resources, both cases give 404. This is a product decision: it is checked against the contract, not "fixed".
Login: "No such email" versus "Wrong password" lets one enumerate accounts. One phrase for both and a comparable response time are needed.
Password reset and registration: the same response for a known and an unknown email ("if the account exists, we sent an email").
The test compares the status and the body. Response time can also reveal a difference (the hash is checked only for an existing account), but because of network noise it is checked over a large series of requests or with a separate tool, not with one expect.
3. Secrets in the URL. A token, key or password in the query (?api_key=...) ends up in proxy logs, browser history and, under a weak Referrer-Policy, the Referer header. Secrets go in Authorization or in a POST body. Also check that a password reset link is single-use and short-lived.
4. Logs and responses. A password, token or card number must be neither in a response (passwordHash, a full PAN) nor in request logs. A tester checks masking (**** 1111) and asks developers to show the logs or looks at them on a test environment.
5. Forgotten surfaces. A public Swagger UI in production, open /actuator and /debug, old API versions without protection (/v1 left after /v2 appeared) also give information and widen the attack surface. The list of endpoints is compared with the documentation.
Limits and alternatives
Hiding the difference between 403 and 404 is worth it when the very existence of a resource is sensitive (accounts, medical records). For public resources 403 may be an honest answer, and hiding only makes diagnostics harder for clients. The decision depends on the product.
Identical login responses hurt usability: the user does not know whether the email or the password was wrong. It is a deliberate compromise that a product usually accepts in favour of security.
The Server and X-Powered-By headers are not a vulnerability by themselves: they are noise that helps reconnaissance. They are removed as hygiene but not treated as a critical defect.
This check automates well for errors (leak patterns) and worse for enumeration (you need to know what counts as "exists").
Common mistakes
Checking only successful responses. Leaks live in errors, so they have to be provoked.
Treating a stack trace as "just a message". It reveals classes, libraries and paths that make a targeted attack easier.
Not comparing responses for "exists" and "does not exist". A difference in status, body or time is a leak channel.
Catching only "500". A leak can also be in a 400 with a detailed DBMS validation error text.
Copying a production token or password into a ticket or chat. It creates the very problem being tested.
Check yourself
Login returns 401 "Wrong password" for an existing email and 404 "User not found" for a non-existing one. What is wrong and how to fix it?
Answer
Different statuses and texts reveal which emails are registered, and passwords can then be guessed for them. The fix: the same status (usually 401) and the same general phrase for both cases, without a noticeable difference in response time.
A leak test looks for the word Exception in the response body, and no response contains it. Does that mean there are no leaks?
Answer
No. The test checks one sign in the responses you provoked. You also need to look at headers (Server, X-Powered-By), errors of different kinds (400, 404, 405, 415) and the difference between responses for existing and non-existing resources.
Related lessons: “Error format and service response headers”, “OWASP API Top 10: access and authentication”, “Security and fintech”.
In an interview.Junior: Besides access, I check that errors do not reveal internals, that someone else's and a non-existent resource look the same, that secrets are not in the URL or in logs, and that responses have no extra fields. Middle/Senior: I deliberately provoke errors (broken JSON, a quote, a long value) and look at the body and headers for traces, SQL and versions. I compare responses for an existing and a non-existing id or email, because a difference in status, text or time gives enumeration. Diagnostics stay in logs under a request id, and the client sees a general response. I remember that 404 instead of 403 is a product decision, checked against the contract.