# Status Code Determinism Audit

> Check that 401 and 403 are chosen consistently across the API, so authorization state cannot be inferred from which code a caller happens to receive. Use when responses use a mix of 401, 403 and 404 and you want the boundary between them to be a state machine, not improvisation

- Skill: `wsh7ash/status-code-determinism-audit` (Agent Skill)
- Install (CLI): `npx get-skill add wsh7ash/status-code-determinism-audit`
- Raw SKILL.md: https://api.skillmd.com/api/skills/wsh7ash/status-code-determinism-audit/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Security
- Author: Wsh7Ash (https://skillmd.com/u/wsh7ash)
- Updated: 2026-11-22
- Page: https://skillmd.com/skills/wsh7ash/status-code-determinism-audit

---


# Status Code Determinism Audit

> Check that 401 and 403 are chosen consistently across the API, so authorization state cannot be inferred from which code a caller happens to receive

**Use when:** responses use a mix of 401, 403 and 404 and you want the boundary between them to be a state machine, not improvisation

**Avoid when:** the API always hides behind a single catch-all code and you have no signal worth auditing

## Procedure

1. Define the intended semantics and write the decision table: no credential gives 401, wrong scope gives 403, hidden object gives 404.
2. Collect responses from every refusal path in your earlier phases and tabulate which code each condition actually produced.
3. Find divergences: the same condition producing different codes on different endpoints, which itself is an inference channel.
4. Test object-level refusals for 403-versus-404 determinism, since that choice either hides or reveals existence.
5. Check error bodies for code-specific wording or machine-readable fields that give away which check fired.
6. Record the audit as a condition-by-code matrix with every divergence as an explicit row in the report.

## Signals

- One endpoint returns 403 for a peer-owned object while its sibling returns 404 for the identical condition.
- Expired credentials sometimes produce 403 instead of 401, blurring authentication from authorization states.
- A machine-readable error code distinguishes forbidden from not-found in one endpoint and not another.
- Wording differs, such as not authorized versus unknown resource, so a caller learns which layer refused without testing.

## Patterns

**1. Decision table**

```text
no-credential=401 bad-role=403 hidden-object=404 unknown-object=404
```

**2. Divergence row**

```text
GET /api/a/{id} peer=404 | GET /api/b/{id} peer=403  -> existence oracle across resources
```

**3. Result row**

```text
divergences=3 worst=peer-object 403-vs-404 across /api/a vs /api/b
```

## Pitfalls

- Treating any 4xx as authorization working, when 400 masquerading as 403 just means the caller cannot parse the rule.
- Overlooking heuristics such as latency and response size, which leak existence even when codes were made uniform.
- Fixing only two endpoints while the rest of the audit continues to emit the inconsistent code pair.

## Done when

- Every refusal condition observed in testing has its actual code recorded next to the intended code in one matrix.
- Object-level 403-versus-404 behavior is documented per endpoint with an explicit existence-leak verdict.

## References

- [RFC 9110 - HTTP status codes](https://www.rfc-editor.org/rfc/rfc9110)
- [PortSwigger - access control](https://portswigger.net/web-security/access-control)

