ServicesSecurity BlueprintInsightsAboutTalk to us

Case study: six API flaws that chain into a platform-wide breach

Six API flaws, each serious on its own. Chained together, they let an outsider become an owner, run their own database queries and take an administrator’s session. The common cause: the API trusted what the browser told it.

This review covers the same LendStack platform as our tenant isolation case study, seen this time from the API, the surface an attacker actually touches. LendStack is a deliberately vulnerable reference build, not a client system. The findings and evidence are public on GitHub.

How we tested

We used a grey-box method: an account on the platform, the API documentation, and no special access. We tested authorization across tenants and roles, every user-controlled input for injection, stored content for script execution, server-side requests, and the money-transfer flow for logic errors. Every finding was proven against a running instance.

The six findings

Anyone could register as an owner (High)

The registration endpoint accepted a role field from the request. Sending "role": "owner" created an owner account straight away. That account could then call an owner-only export and read the tenant’s 5 invoices. An analyst calling the same endpoint was correctly refused, which proves the role check existed. It just trusted the wrong source.

A search box that ran SQL (Critical)

An admin search built its database query by joining strings. A normal search answered in about 30ms. A search containing an injected pg_sleep(5) took about 5 seconds, which proves our input was running as SQL. From there, an attacker can read data, change it, or slow the system down.

Another customer’s invoice, by changing an ID (High)

Signed in as one customer, we requested an invoice ID belonging to another and got 200 OK with their invoice. The query had no tenant filter, and the database policy that should have caught it did not apply.

A stored script that stole an admin’s session (High)

A text field was saved and later shown to administrators as HTML. A script stored there ran in the admin’s browser and could read their session token.

A webhook that could reach internal services (High)

The server fetched any URL a user supplied for a webhook, including addresses inside its own network.

Transfers that ran backwards or twice (Critical)

A transfer with a negative amount was accepted and reversed the ledger. Sending the same transfer twice with the same idempotency key created two separate $1,000 transfers, when the key should have stopped the second one.

How the flaws chain

  1. Register as an owner by naming the role in the request.
  2. Use that account’s search to run SQL and read data.
  3. Store a script where an administrator will see it.
  4. When an administrator logs in, take their session.
  5. Use the administrator’s session to export the platform’s data.

Fixing any single flaw breaks one link. It does not fix the system, because the same assumption sits behind all six.

The fix: decide on the server, every time

  • Never accept a role or tenant from the client. Take them from the signed-in session, and add people through invitations.
  • Use parameterized queries everywhere, and keep database errors out of responses.
  • Filter every query by tenant, and make the database enforce it too.
  • Render user text as text, never as HTML, and add a Content-Security-Policy.
  • Block private and metadata addresses for any URL the server fetches.
  • Make money rules part of the data: amounts must be positive, idempotency keys must be unique, and rows are locked while a transfer runs.

What this means for your product

If your API takes a user’s word for who they are, what they own or what an amount should be, the front end is your only defense, and it is not one. An Application & API Security review tests exactly these paths and shows you, with evidence, which ones are open.

Newsletter

Get new insights by email.

Short, practical notes on security and technology risk, sent only when there’s something worth reading. Never more than one a month.