# Authorization Testing Automation
> Mechanizing the one test that finds most access-control bugs: replay every request as every other principal (higher role, lower role, other tenant, anonymous) and diff the result. Done in the proxy while hunting, and in CI as regression tests.
## How it works
Scanners can't know the policy, but they can execute a **matrix**. The core artifact is an authorization matrix: features (endpoints/operations) × logical roles (OWASP adds a third dimension, *data*, for object ownership). Testing then means:
1. Capture traffic as the highest-privileged principal (or as the object owner).
2. Re-issue each request with a lower-privileged session, a peer in another tenant, and no session.
3. Compare status, length and body markers. A "denied" that returns `200` with the same body is a finding.
HackerOne's "permissions mapping" (list roles, list actions, test every cell) and the "three-request" IDOR method are manual versions of the same loop. Snyk's argument for why this matters more now: AI coding agents write endpoints that authenticate, handle not-found and read cleanly, but omit the org-scoping condition. The rule ("invoices belong to orgs; cross-org reads are never legit") lives in the product, not the code, so pattern scanners have nothing to match.
## Techniques / tools
**In Burp (hunting):**
| Tool | What it does | Notes |
|---|---|---|
| **Autorize** | shadows your browsing; re-sends each request with the attacker's injected headers/cookies (low-priv) and optionally unauthenticated; flags red `Bypassed!` and orange `Is enforced??` (uncertain, inspect manually) | configure *enforcement detectors* (body regex or length for "denied") or you'll drown in false positives; add interception filters scoped to the API host |
| **AuthMatrix** | define users, roles and requests explicitly, then run the full matrix | good for repeatable role × request grids on an engagement |
| **Permitter** | replays proxy history or site-map requests across configured roles via regex-based session-token substitution; optional unauthenticated pass | endpoint exclusion, delays, dedup, CSV/HTML export |
| **Session Switcher** (Doyensec) | saves named sessions and swaps cookies/headers in the request editor in one click; auto-refreshes from proxy traffic | for manual IDOR/privesc in Repeater |
| Burp authenticated scanning | recorded login replay, so the scanner reaches privileged areas | coverage, not authz decisions |
**GraphQL**: one object is often reachable through several resolvers (`invoice(id:)`, `node(id:)` via Relay's Global Object Identification (IDs are base64 `Type:id`), `me { invoices }`, nested edges). Enumerate every field that returns the target type from the introspection `schema.json` (or Clairvoyance if introspection is off), then as user B request user A's object through **every path in one aliased query**. The spec isolates errors per alias, so the response shows exactly which resolver lacks the ownership check:
```graphql
query {
control: invoice(id: "<B_INVOICE>") { id total }
viaInvoice: invoice(id: "<A_INVOICE>") { id total }
viaNode: node(id: "<A_NODE_ID>") { ... on Invoice { id total } }
}
```
**Autonomous agents**: Wiz's Red Agent found BOLA in an airline GraphQL booking API (predictable integer IDs, no backend check) and escalated to read/write over passengers' PII and live itineraries. That is evidence that matrix-style probing automates well once sessions are supplied.
**In CI (regression):**
- **OWASP Authorization Testing Automation**: encode the matrix as XML (`<roles>` ANONYMOUS/BASIC/ADMIN, `<services>` with URI, method and allowed roles, `<services-testing>` payloads). Integration tests iterate every combination and report the exact violating cell.
- **ExploitSpec**: turns a confirmed BOLA/IDOR (from cURL/HAR, redacted) into a spec with isolated actors, captured dynamic values and the boundary to preserve. It must prove **RED** (vulnerable), then **GREEN** (fixed), then **STABLE** before it can fail the build; output as text, JSON or JUnit.
- Policy-as-code engines make the matrix testable directly; see [[Authorization Policy Engines]].
## Pitfalls
- Differential testing needs **two of everything**: two users per role and two tenants. A single account can't show horizontal or cross-tenant failures.
- Detector tuning matters more than the tool. Redirect-to-login responses that still carry data, `200 {"error":"forbidden"}`, and identical-length error pages all mislead naive diffing.
- Writes and deletes need real objects owned by the *other* principal, with state checked afterwards. A `200` doesn't prove persistence.
## Related
- [[Authorization Security]]
- [[Broken Access Control]]
- [[IDOR Testing Methodology]]
- [[BOLA in APIs]]
- [[GraphQL Authorization Flaws]]
- [[Burp Suite Extensions]]
- [[Multi-Tenant Isolation]]
## Sources
- [[raw/danaepp.com/automate-your-api-hacking-with-autorize-6597|Automate your API hacking with Autorize]]
- [[raw/whiteoaksecurity.com/automating-authorization-testing-authmatrix-part-1-909|Automating Authorization Testing: AuthMatrix Part 1]]
- [[raw/portswigger.net/permitter-burp-extension-for-multi-role-authorization-testing-15356|Permitter: Burp extension for multi-role authorization testing]]
- [[raw/blog.doyensec.com/introducing-session-switcher-swap-burp-sessions-with-one-click-11406|Introducing Session Switcher. Swap Burp Sessions with One Click!]]
- [[raw/portswigger.net/improvements-to-burp-suite-authenticated-scanning-5596|Improvements to Burp Suite authenticated scanning]]
- [[raw/cheatsheetseries.owasp.org/authorization-testing-automation-cheat-sheet-owasp-3975|Authorization Testing Automation Cheat Sheet - OWASP]]
- [[raw/pazent.github.io/exploitspec-bola-idor-regression-tests-from-bounded-redacted-har-input-11961|ExploitSpec — BOLA/IDOR regression tests from bounded, redacted HAR input]]
- [[raw/hackerone.com/how-to-find-broken-access-control-vulnerabilities-in-the-wild-hackeron-2736|How To Find Broken Access Control Vulnerabilities in the Wild - HackerOne]]
- [[raw/thexssrat.medium.com/the-three-request-idor-method-how-i-find-broken-access-control-before-13001|The Three-Request IDOR Method: How I Find Broken Access Control Before Breakfast]]
- [[raw/dev.to/graphql-bola-one-object-many-paths-and-how-to-prove-the-gap-14345|GraphQL BOLA: one object, many paths, and how to prove the gap]]
- [[raw/wiz.io/the-red-agent-pov-exploiting-broken-object-level-authorization-in-an-a-9944|The Red Agent POV: Exploiting Broken Object-Level Authorization in an Airline GraphQL API]]
- [[raw/snyk.io/why-ai-coding-agents-keep-writing-broken-access-control-12183|Why AI Coding Agents Keep Writing Broken Access Control]]