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.

terminal
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 matrix

1. Draft a policy with policy init#

terminal
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.policy

The draft is built from the routes DeployReady discovered, using simple heuristics. It is marked "draft": true with a _comment saying so.

Route looks likeDrafted access
Contains /admin, /internal, /staff, ...anonymous: none, user: none, admin: manage
/users/:id, /accounts, /profile, /meanonymous: none, user: own, admin: manage
Public catalog (/products, /posts, /categories, /pricing, ...)anonymous: read, user: read, admin: manage, tenantScoped: false
Any other recordanonymous: none, user: own, admin: manage
/batch, /bulk; .../export, .csvKept with "sideEffectFree": false: not requested until you set it to true
Login, logout, auth callbacks, webhooks, healthExcluded (listed under _excluded)
/graphqlgraphql: { endpoint, introspection: "deny" }

2. Identities#

.deployready.json
{
  "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 contain TOKEN, JWT, SESSION, COOKIE or AUTH, so a shared config cannot make the scanner read an unrelated secret), token (a literal bearer token; avoid it in a committed file), or session (a saved login session; its cookies and bearer token are sent only to the scan target). Only the anonymous role may have none, and an anonymous identity is always added.
  • params (route parameter to value, for every route) and objects(resource name, then parameter, then value) name the identity's own records. Use objects for record ids. User-like parameters and tenant-like parameters fall back to tenant and to JWT claims (sub, org_id). Nothing is guessed: a route whose parameters no identity declares is reported as untested.
  • --token and --token-b are added as the identities token and token-b (role user).
  • 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#

.deployready.json
{
  "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" }] }
    }
  }
}
LevelReadChange
noneNothing (not even the route)Nothing
readEvery recordNothing
ownOwn records onlyOwn records only
manageEvery recordEvery record
  • tenantScoped (default true): no level reaches a record of another tenant, except for an identity without a tenant (platform-wide).
  • A role missing from access is none; "*" 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#

TestHowRule
Missing server-side authorizationAnonymous requests a route or record the policy does not open to anonymousauthz-missing-auth
Vertical (function-level, BFLA)A role requests a route reserved for other roles; the answer is compared with an allowed identity’s answerauthz-bfla
Horizontal (object-level, BOLA/IDOR)User A requests user B’s record, by path, query parameter, or GraphQL idauthz-bola
Cross-tenantA record belonging to another tenantauthz-cross-tenant
Nested idsA’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 filteringA’s list route must not contain B’s recordsauthz-bola / authz-cross-tenant
BatchAn ids array that mixes A’s and B’s idsauthz-bola / authz-cross-tenant
Export and downloadThe same checks on export routes, using read requests onlyas above
GraphQL introspectionAn anonymous __schema querygraphql-introspection (warning)
Cross-identity write (stateful only)A changes a text field of B’s record; B reads it backauthz-unauthorized-write
Cross-identity delete (stateful only)B creates a fresh record (the resource body), A deletes it, B reads it backauthz-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 themauthz-mass-assignment
Privilege escalation through role fields (stateful only)role, isAdmin, or permissions on the identity’s own record, then a read-backauthz-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:

VerdictMeaning
allowed as expected / denied as expectedThe 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.
violationProven. 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.
inconclusiveNeither 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.
untestedCould 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, or ownedTargets in 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 declared sideEffectFree. Side-effect-looking GET paths (export, logout, and similar) and routes in unsafeRoutes are skipped unless declared sideEffectFree. An unsafeRoutes route 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": true and 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 (or passive) 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.
terminal
# 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
.deployready.json (needed for 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.