How detection works
Your own coding-agent model reads each handler and proposes a structured controlHint; the LLM-free CLI compiles it into an enforced x-security control — but only after it verifies the finding cites a real file:line in your code.
cite.quote against the line range. There is no ?? "unknown" default, no regex backfill, no synthesized citation. An unverifiable finding becomes reviewRequired; it never becomes a rule.Three passes
Each pass narrows the problem: find the routes, classify the shape, emit the policy. Anything the model can't justify drops to reviewRequired; it is never a silent best-effort.
1. Inventory + context map
The agent works on any HTTP handler it can read, framework-agnostic by default. Routes and handlers are resolved structurally, with a parallel ripgrep backstop that catches anything the structural pass missed; under-matching is the failure mode we measure. The same inventory is available deterministically via xsecurity routes.
2. Profile classification
Six profiles drive the defaults: auth-endpoint, standard-crud, file-upload, webhook-receiver, public-read-only, admin-panel. Ambiguous routes drop to reviewRequired. The agent never guesses. The agent emits only deltas from the profile base, keeping output short and review fast.
3. Per-route findings
For each route, the agent reads the handler body, model, validator, middleware, and response sites, then proposes controlHint findings validated against the v0.8 schema, or returns reviewRequired with reasons. Every finding cites file:line with a verbatim quote.
The 9-kind control taxonomy
Every detected control is one of these nine controlHint.kind values. The model supplies the kind plus its required fields; the compiler enforces the per-kind required set and drops an incomplete descriptor rather than fabricating a default.
| Field | Type | Default | Description |
|---|---|---|---|
| injectionGuard | sink | — | A body/query field flows into a sink (sql · nosql · os-command · xpath · ldap · code-eval · xss · deserialization · ai-prompt). Carries the guarded param. |
| authentication | gate | — | A sensitive route with no auth gate. Requires the caller to prove identity before the handler runs. |
| authorization | rule | — | Object/function-level access (BOLA/BFLA). Requires param + principalRef and is location-aware; see below. |
| denyUnknownFields | shape | — | Mass-assignment / BOPLA guard: reject request bodies carrying keys the route never declared. |
| rateLimit | throttle | — | An unthrottled credential/abuse surface. Throttles per identifier over a window. |
| paramConstraint | tightness | — | Structural perimeter tightness: paramType, pattern, min/max, min/maxLength on a declared field. |
| contentType | allowlist | — | Restrict accepted request content types to an allowlist (e.g. application/json only). |
| responseShape | egress | — | Constrain the response body shape on the way out; guards over-exposed or hijackable responses. |
| domainAllowlist | egress | — | SSRF / open-redirect: restrict outbound hosts a proxy/fetch route may reach to an allowlist. |
Location-aware authorization
Object-level authorization (BOLA) only works if the policy knows where the object identifier lives in the request. A controlHint of kind authorization carries a location (one of path, query, body, or header) that the model cites and the compiler turns into request.<segment>.<param>.
| Field | Type | Default | Description |
|---|---|---|---|
| param | string | — | The request field carrying the object identifier (REQUIRED to emit). |
| principalRef | string | — | The caller-identity reference compared against the resource owner, e.g. jwt.sub (REQUIRED). |
| operator | enum | equals | How the resource value is compared to the principal. |
| location | enum | path | path · query · body · header. Defaults to path (the /resource/:id case). |
path made query-, body-, and header-keyed ownership inexpressible, a real gap in common API patterns. Making location first-class is what lets the agent express ownership checks wherever the identifier actually lives. How much of an ownership check each gateway can enforce varies. See the gateway matrix for per-target support.The verification gates
Every candidate finding passes through deterministic gates before it reaches disk as a policy. Any single failure drops it to reviewRequired. Each gate is a real x-security verb you can run by hand.
| Field | Type | Default | Description |
|---|---|---|---|
| schema | structural | v0.8 | Validates against the published x-security schema. Strict: unknown fields are an error. (xsecurity verify-finding) |
| evidence | semantic | — | Every finding must cite a source file:line with a byte-matching quote. No evidence → dropped. (xsecurity verify-finding) |
| tightness | semantic | — | Rejects loose constraints that look like protection but aren't. (xsecurity verify-finding) |
| consistency | semantic | — | Whole-route gate: composes findings and checks cross-control consistency. (xsecurity verify-route) |
| grounding | structural | — | Reconciles mount prefixes and grounds agent-claimed routes against the deterministic extractor. (xsecurity reconcile-inventory) |
| audit | structural | — | Re-validates every stored policy control and proves citation coverage; exit 2 if any control lacks a byte-matching cite. (xsecurity audit) |
| fidelity | semantic | — | Flags fields the chosen gateway cannot enforce; --strict-fidelity fails on them. (xsecurity report) |
Deterministic, diffable output
The compile step is deterministic: same input, byte-identical output. That holds for both the policy files xsecurity compile writes and the gateway config xsecurity generate emits — so you can commit generated artifacts to git, diff them like ordinary source, and review the blast radius of a spec change with xsecurity diff.
Proof: how findings earn trust
Detection accuracy is the product, so every finding has to prove itself rather than be taken on faith.
Every rule cites your code
Every emitted control cites the exact file:line of the route it protects. A finding without a citation is treated as a model failure and dropped; it never reaches disk as a rule. You can verify any rule in one click.
Deterministic gate, no silent defaults
A bundled, LLM-free verifier checks every control the model emits against the real route inventory. Anything it cannot pin to your code is flagged reviewRequired for a human instead of being written as a loose rule. Loose protection that looks tight is the worst outcome.
x-security schema is Apache-2.0. Fork it, embed it, contribute fields back. See github.com/ZeeshanSultan/x-security.