Features
Authorization Testing
Since 0.6.0, DeployReady can test your app against an explicit authorization policy: for each resource, each identity, and each action it decides what should happen, sends the requests, and reports what did happen.
This is the active engine from 0.5.0 (field-level verdicts, safety levels, a request budget, redacted proof) driven by a policy instead of two tokens. The matrix runs when .deployready.json contains active.policy or active.identities. Without them, --active --token ... --token-b ... keeps working as before: see Active Security Testing.
npx deployready@latest policy init . # draft a policy from your routes
# review it, set "draft": false, add identities
npx deployready@latest analyze . --active --dry-run # preview the plan, send nothing
npx deployready@latest analyze . --active # run the matrix1. Draft a policy with policy init#
npx deployready@latest policy init . # writes active.policy (+ example identities) into .deployready.json
npx deployready@latest policy init . --print # print the draft instead of writing it
npx deployready@latest policy init . --force # replace an existing active.policyThe draft is built from the routes DeployReady discovered, using simple heuristics. It is marked "draft": true with a _comment saying so.
| Route looks like | Drafted access |
|---|---|
Contains /admin, /internal, /staff, ... | anonymous: none, user: none, admin: manage |
/users/:id, /accounts, /profile, /me | anonymous: none, user: own, admin: manage |
Public catalog (/products, /posts, /categories, /pricing, ...) | anonymous: read, user: read, admin: manage, tenantScoped: false |
| Any other record | anonymous: none, user: own, admin: manage |
/batch, /bulk; .../export, .csv | Kept with "sideEffectFree": false: not requested until you set it to true |
| Login, logout, auth callbacks, webhooks, health | Excluded (listed under _excluded) |
/graphql | graphql: { endpoint, introspection: "deny" } |
2. Identities#
{
"active": {
"identities": [
{ "name": "anonymous", "role": "anonymous" },
{ "name": "alice", "role": "user", "tenant": "acme", "tokenEnv": "DR_ALICE_TOKEN",
"params": { "userId": "u_alice", "org": "acme" },
"objects": { "invoices": { "id": "inv_a" }, "projects": { "id": "p_acme" } } },
{ "name": "bob", "role": "user", "tenant": "acme", "session": "bob" },
{ "name": "admin", "role": "admin", "tokenEnv": "DR_ADMIN_TOKEN" },
{ "name": "other-tenant", "role": "user", "tenant": "globex", "tokenEnv": "DR_EVE_TOKEN",
"objects": { "invoices": { "id": "inv_e" } } }
]
}
}- Credential, one of:
tokenEnv(an environment variable holding a bearer token; the variable name must containTOKEN,JWT,SESSION,COOKIEorAUTH, so a shared config cannot make the scanner read an unrelated secret),token(a literal bearer token; avoid it in a committed file), orsession(a saved login session; its cookies and bearer token are sent only to the scan target). Only theanonymousrole may have none, and an anonymous identity is always added. params(route parameter to value, for every route) andobjects(resource name, then parameter, then value) name the identity's own records. Useobjectsfor record ids. User-like parameters and tenant-like parameters fall back totenantand to JWT claims (sub,org_id). Nothing is guessed: a route whose parameters no identity declares is reported as untested.--tokenand--token-bare added as the identitiestokenandtoken-b(roleuser).- An identity that cannot be built (variable unset, session missing or expired) stays in the matrix with its cells marked untested and the reason.
3. The policy matrix#
{
"active": {
"policy": {
"draft": false,
"resources": [
{ "name": "invoices",
"routes": ["GET /api/invoices", "GET /api/invoices/:id", "PATCH /api/invoices/:id",
"DELETE /api/invoices/:id", "POST /api/invoices",
"GET /api/invoices/:id/download", "GET /api/user-invoices?userId=:userId",
{ "route": "POST /api/invoices/batch-get", "batchField": "ids", "sideEffectFree": true }],
"access": { "anonymous": "none", "user": "own", "admin": "manage" },
"tenantScoped": true,
"body": { "title": "DeployReady test invoice" } },
{ "name": "admin-stats", "routes": ["GET /admin/stats"],
"access": { "user": "none", "admin": "manage" } }
],
"graphql": { "endpoint": "/graphql", "introspection": "deny",
"queries": [{ "resource": "invoices",
"query": "query($id: ID!) { invoice(id: $id) { id total } }",
"variable": "id" }] }
}
}
}| Level | Read | Change |
|---|---|---|
none | Nothing (not even the route) | Nothing |
read | Every record | Nothing |
own | Own records only | Own records only |
manage | Every record | Every record |
tenantScoped(defaulttrue): no level reaches a record of another tenant, except for an identity without atenant(platform-wide).- A role missing from
accessisnone;"*"sets a default. - Routes accept
:param,{param}and[param], and query bindings such as?userId=:userId. - GraphQL queries must be queries. A mutation or subscription is rejected.
4. What is tested#
| Test | How | Rule |
|---|---|---|
| Missing server-side authorization | Anonymous requests a route or record the policy does not open to anonymous | authz-missing-auth |
| Vertical (function-level, BFLA) | A role requests a route reserved for other roles; the answer is compared with an allowed identity’s answer | authz-bfla |
| Horizontal (object-level, BOLA/IDOR) | User A requests user B’s record, by path, query parameter, or GraphQL id | authz-bola |
| Cross-tenant | A record belonging to another tenant | authz-cross-tenant |
| Nested ids | A’s own parent id with B’s child id, such as /orgs/<A’s org>/projects/<B’s project> | authz-cross-tenant / authz-bola |
| List filtering | A’s list route must not contain B’s records | authz-bola / authz-cross-tenant |
| Batch | An ids array that mixes A’s and B’s ids | authz-bola / authz-cross-tenant |
| Export and download | The same checks on export routes, using read requests only | as above |
| GraphQL introspection | An anonymous __schema query | graphql-introspection (warning) |
| Cross-identity write (stateful only) | A changes a text field of B’s record; B reads it back | authz-unauthorized-write |
| Cross-identity delete (stateful only) | B creates a fresh record (the resource body), A deletes it, B reads it back | authz-unauthorized-write |
| Mass assignment (stateful only) | Extra ownerId, tenantId, price, amount, or verified fields on create or update of the identity’s own record, then a read-back; a create is compared with a control create without them | authz-mass-assignment |
| Privilege escalation through role fields (stateful only) | role, isAdmin, or permissions on the identity’s own record, then a read-back | authz-privilege-escalation |
Only fields that already exist on the record are tried, and a value counts only when the read-back shows the client's value where the record had a different one.
5. Verdicts#
Every cell of (resource route, identity, record owner) gets one verdict:
| Verdict | Meaning |
|---|---|
| allowed as expected / denied as expected | The app did what the policy says. A denial means the owner’s private values are absent from the answer while an allowed identity can read them, or the answer is an explicit 401/403. |
| violation | Proven. For reads, the owner’s private values appear in the answer: compared field by field, at any status code. An echo of the id is not enough, volatile fields are learned from repeated baselines, and an anonymous control tells a public record from a leak. For writes, the read-back shows the change. |
| inconclusive | Neither proven safe nor proven vulnerable: for example an SPA fallback page, a suspected leak with only one non-sensitive value, or a refusal of a request the policy allows. |
| untested | Could not run, with the reason: safety level, unsafeRoutes, missing ids, unavailable identity, or the request budget. |
A violation needs leaked data or a read-back, never a status code alone. Each violation carries a plain-English statement (for example User "alice" (role user, tenant acme) could read invoices of "bob") and becomes a finding with a redacted proof: a curl command whose credential is a placeholder such as $ALICE_AUTH, the status, the response with the owner's values masked, and the control. Violations of one rule on one route are grouped into one finding.
The matrix in the report#
Every report from a matrix run includes the matrix itself: the cells with their verdicts (allowed or denied as expected, violation, inconclusive, untested), the identities, a summary, and the routes your policy does not cover. It appears in --json (under authz), the Markdown report, and the HTML dashboard. See Reports and dashboard.
6. Safety#
- The same gates as every active scan: opt-in (
--active), a confirmation prompt (unless--yes), loopback only unless you name an owned host (--i-own-this-target, orownedTargetsin your user config; the project file cannot add hosts), and a hard request budget (active.maxRequests, default 200). read-only(the default) sends GET requests, plus POST only for GraphQL queries and batch routes you declaredsideEffectFree. Side-effect-looking GET paths (export, logout, and similar) and routes inunsafeRoutesare skipped unless declaredsideEffectFree. AnunsafeRoutesroute is never used as a read-back either.- Writes are stateful-only. Anything that writes needs
--safety-level stateful, which is refused unless the config declares"disposableEnvironment": trueand the target is loopback or an owned host. Writes run after all reads, and changed fields are restored where the owner may do so. --dry-run(orpassive) prints the matrix plan, with each cell, the expected outcome, and an upper bound of requests, and sends nothing. Saved sessions are not even loaded.- Credentials are never written to a report. Response bodies are masked and redacted.
# the plan only
npx deployready@latest analyze . --active --dry-run
# the read-only matrix (default safety level)
npx deployready@latest analyze . --active
# writes too: disposable environment only
npx deployready@latest analyze . --active --safety-level stateful{ "disposableEnvironment": true }The four levels (passive, read-only, controlled-active, stateful) are described under Active Security Testing.
Re-checking a finding#
verify(interactive shell and MCP) re-runs the matrix for the finding's route with the same identities from .deployready.json, reading credentials from the environment and saved sessions. It returns still-present with a fresh proof, fixed when the cells are denied as expected, or inconclusive with the reason. See Verification and proof.
What it does not do#
- It tests only what your policy says. Routes the policy does not cover are listed in the report as uncovered, not tested.
- It does not guess ids. A route whose parameters no identity declares is untested.
- A policy that is wrong tests the wrong thing. The draft from policy init is a starting point written with simple heuristics.
- It is not a penetration test, and a matrix with no violations means none were proven in the cells that ran, not that the app is secure.
Identities can also come from saved browser sessions: see Login Sessions.