Coverage area · Checked automatically

API security: authorization and abuse paths

APIs expose your data model directly, so the most common API bugs are about who may touch which object. OpenRouting checks imported API collections for these patterns and reviews the code findings Semgrep raises.

routes/accounts.ts1const acct = await Account2 .findById(req.params.id);3Object.assign(acct, req.body);4await acct.save();APIwhat this review answersObject fetched without owner check?Request body mass-assigned?Rate limits on costly endpoints?$ verdict REAL ISSUE$ fix scope to owner, allow-list fields▍

Illustrative example of how a finding in this area is reviewed when a scanner raises one.

What OpenRouting checks today

Checked automatically

Import a Postman, OpenAPI, Swagger, HAR, Insomnia or Bruno collection and the API-collection rules check it for missing or weak auth, guessable IDs, mass-assignment-shaped requests, secrets or PII in URLs and over-shared responses, without sending any traffic. In code, Semgrep flags mass assignment in Django, Rails and .NET and missing CSRF protection, reviewed by the access-control agent. Not checked: a missing ownership check in handler code is only reviewed when a scanner raises a finding on it.

Why this area matters

Broken object-level authorization (BOLA, also called IDOR) has been number one on the OWASP API Security Top 10 since the list began: an endpoint takes an object ID from the request and returns or updates it without checking the caller owns it. Mass assignment and missing function-level authorization follow close behind (CWE-639, CWE-862, CWE-915).

These bugs are hard for pattern rules because the code looks normal — the problem is a check that isn't there. An API collection shows the shape of every endpoint at once, so guessable IDs, missing auth and mass-assignment-shaped bodies stand out; in code, the access-control agent reads the handler, the lookup and the surrounding middleware to decide whether the object is scoped to the caller.

What goes wrong in real applications

  • Broken object-level authorization

    Looking up an object by an ID from the request without scoping it to the caller lets any user read or change other users' records by changing the ID.

  • Mass assignment

    Copying the request body straight onto a model lets callers set fields they shouldn't, such as role, owner or price.

  • Missing function-level authorization

    Admin or internal endpoints that only check that a user is logged in, not what they are allowed to do.

  • Unbounded or costly operations

    No pagination limits, no rate limiting and unrestricted GraphQL query depth let one client exhaust the backend or scrape the dataset.

Sample: the risky pattern and the fix

Riskysrc/routes/accounts.ts
router.patch("/api/accounts/:id", requireLogin, async (req, res) => {
  const account = await Account.findById(req.params.id);
  if (!account) return res.sendStatus(404);
  Object.assign(account, req.body);
  await account.save();
  res.json(account);
});
Safersrc/routes/accounts.ts
const UpdateAccount = z.object({
  displayName: z.string().max(80).optional(),
  timezone: z.string().max(64).optional(),
});

router.patch("/api/accounts/:id", requireLogin, async (req, res) => {
  const account = await Account.findOne({ _id: req.params.id, ownerId: req.user.id });
  if (!account) return res.sendStatus(404);
  account.set(UpdateAccount.parse(req.body));
  await account.save();
  res.json(account.toPublicJSON());
});

Any logged-in user can update any account by changing the ID, and can set any field — including role or owner — because the body is copied wholesale. The fix scopes the lookup to the caller's own account and only accepts two validated fields.

Illustrative code, simplified for clarity — not taken from a customer repository.

What to look for in your code

  • Handlers that load objects by a request-supplied ID without an owner or tenant filter
  • Request bodies spread or assigned directly onto models
  • Routes missing authorization middleware or role checks
  • GraphQL resolvers without per-object authorization, and missing depth or complexity limits
  • Whether scoping is enforced elsewhere — a base query, a policy layer or middleware (the main false-positive signal)

Scope and limits

  • It reads your handlers; it doesn't send requests to your API, so authorization enforced only at a gateway or proxy may not be visible.
  • Rate limits configured outside the repository (CDN, API gateway) aren't seen, so a missing-limit finding may already be covered.

The checklist above is broader than what runs automatically; see what OpenRouting checks today. Where a scanner does run, it surfaces candidates and a review agent decides whether each one is real — it doesn't promise to find every issue.

Review agents for this area

These agents give the verdict and fix when a scanner raises a finding here.

Common questions

Can a static scan really find IDOR?

Some of it. The API-collection rules flag endpoints with guessable IDs and missing auth; in code, a missing ownership check is reviewed when a finding points at it. It won't find every case, especially when authorization logic is spread across services.

Does it cover GraphQL?

Not specifically. There are no GraphQL rules or collection import today, so per-resolver authorization and query depth limits are a manual check. It never executes queries against your API.