AC-032 Conformance not caught CS-GAP-008

Wrong, expired or under-privileged credentials are accepted

The server accepts too much

How to run this card's commands yourself

1. The problem

In one sentence

The server checks that a credential is present, but not that it is valid, current or allowed to do this.

A story

The spec says GET /lenient/wrong-auth needs a bearer token. The server refuses a request with no token (401). But it accepts any value in the header, including Bearer not-a-real-token. A former employee’s token, an expired token and a token meant for another service all open the route.

Why it hurts

Authentication has three questions: is there a credential, is it genuine and current, and is its owner allowed to do this? A server that answers only the first has a lock that opens for anything shaped like a key.

  • For developers: the check usually stops at “the header starts with Bearer”. Token verification (signature, expiry, scope) is a separate step and is easy to leave out of one route.
  • For managers: an access control that only looks for the presence of a token is not access control. This is a security exposure, and for expired or under-privileged tokens it can hide a data-leak path for a long time.
  • For DevOps: test refusal with the realistic wrong cases: a wrong token, an expired one, one with too few rights. Do it for each secured route class.

Example

The spec declares a bearer token and a 401:

security:
  - bearerAuth: []
responses:
  "200":
    $ref: "#/components/responses/Secret"
  "401":
    $ref: "#/components/responses/Unauthorized"

The two servers in the sandbox, asked with Authorization: Bearer not-a-real-token:

lenient/wrong-auth  GET  ->  200 OK            {"secret":"s3cret"}
strict/wrong-auth   GET  ->  401 Unauthorized  {"code":"unauthorized","message":"a valid bearer token is required"}

How to detect it without clrsig

  • curl -i -H 'Authorization: Bearer not-a-real-token' URL. A correct server answers 401.
  • Repeat with an expired token, and with a valid token of a user who should not have access (403).

How to fix it

There are two usual causes:

  1. The code is wrong (almost always). Verify the token on every secured route: signature, expiry, and the rights it grants. Use one shared mechanism, not a check per route.
  2. The spec is wrong. Its security entry promises more than the system does. Fix the system first, then the words.

Treat a confirmed hole as a security incident. Never remove the check to make a pipeline green.

AC-031 A request without credentials is accepted, AC-035 Authentication error codes are mixed up, AC-033 Loose validation: enums, boundaries, unknown fields. Failure-catalog demo: FM-025-02 (authentication error code confusion).

Words used on this page are explained once in the glossary.

2. How clrsig helps

Check

No built-in check: this is a known gap, CS-GAP-008, and the state is not caught. clrsig’s negative probes only remove credentials (CS-PROBE-004). They do not send a wrong, expired or under-privileged one. The reliable answer is a scenario with one step per bad token, which says what the correct behaviour is. This is the recommended approach, and it stays right if a probe is added later.

Command

First, what the negative probes say about this route. The operation is a GET, so nothing is written:

clrsig conform specs/conform-fail.yaml \
  -b http://localhost:8080/conform-fail \
  --env clrsig/environments/conform-fail.yaml \
  --negative --paths /lenient/wrong-auth --explain

Output from clrsig v0.21.0, recorded on 2026-11-30. The lines for the 75 operations that --paths skipped are left out by grep -v '^ SKIP'; no line is edited.

conform-fail API  1.0.0
Base URL: http://localhost:8080/conform-fail
Limited by --paths /lenient/wrong-auth

  PASS  GET     /lenient/wrong-auth  200  14ms

PASSED  76 operations  ·  1 passed  ·  0 failed  ·  75 skipped  15ms

Negative conformance probes — conform-fail API 1.0.0
  PASS  GET /lenient/wrong-auth — no credentials (expect 401/403)  401  1ms

PASSED  1 probe  ·  1 passed  ·  0 failed  ·  0 skipped  ·  0 errors  2ms

It passes (exit code 0): the server does refuse a request with no token. The wrong token is never tried.

Now the scenario that tries it. Save it as wrong-credentials.yaml. It sends two GET requests:

schemaVersion: "1"
title: wrong credentials are refused
steps:
  - label: lenient route, a token that is wrong
    request:
      method: GET
      url: "{{baseUrl}}/lenient/wrong-auth"
      headers: [{ name: Authorization, value: "Bearer not-a-real-token" }]
    assertions:
      - { type: status, operator: eq, expected: 401 }
    failPolicy: continue
  - label: strict route, a token that is wrong
    request:
      method: GET
      url: "{{baseUrl}}/strict/wrong-auth"
      headers: [{ name: Authorization, value: "Bearer not-a-real-token" }]
    assertions:
      - { type: status, operator: eq, expected: 401 }
    failPolicy: continue
clrsig run wrong-credentials.yaml \
  --env clrsig/environments/conform-fail.yaml \
  --spec specs/conform-fail.yaml

Exit code: 0 all steps pass, 1 a step failed, 2 the scenario or the setup is broken. Here it is 1.

What you see

Output from clrsig v0.21.0, recorded on 2026-11-30:

Scenario: wrong credentials are refused

  FAIL  lenient route, a token that is wrong  200  21ms
         ✗ status eq 401: expected "401"; got "200"
  PASS  strict route, a token that is wrong  401  3ms
         ✓ status eq 401

FAILED  1 passed, 1 failed, 0 skipped  (1/2 assertions passed)  29ms

How to read it: the lenient route accepted a made-up token (got "200"). The strict route refused it, as the contract says it should.

Where to look

  • Desktop app: open the scenario and run it; each step shows its assertion result.
  • Reports: --format json and junit on clrsig run list the failed assertion.
  • GitHub Action: use command: run with the scenario, env and spec inputs; spec replaces the scenario’s specFile. Older releases of the Action ignored spec with run; if you use one, add specFile: specs/conform-fail.yaml to the scenario instead (the path is relative to the scenario file) (setup and upgrading).

How clrsig helps you fix it

The failed step names exactly which route accepted which bad token. It cannot tell you why the server accepted it. For an expired or under-privileged token, add one step per case, each with its own token.

Limits

  • This is a known gap: the built-in probes do not send wrong credentials. You write each case.
  • A scenario needs real wrong tokens for your system (expired, a user with fewer rights). Keep them in the environment, never in files in the repository.

More ways

Nothing yet.

3. Video brief for Google NotebookLM

VIDEO BRIEF — AC-032 · Wrong, expired or under-privileged credentials are accepted
Length: 5 to 7 minutes. Language: English. Audience: developers, with a line each for managers and DevOps.
One idea: a lock that opens for anything shaped like a key is no lock; check that credentials are genuine, current and allowed.
Open with this story: The spec says an operation needs a bearer token. The server refuses a request with no token. But it accepts any value in the header, including a made-up token. A former employee's token, an expired token and a token meant for another service all open the route.
Say these facts, in this order:
1. Authentication has three questions: is there a credential, is it genuine and current, and is its owner allowed to do this?
2. The lenient server answers only the first question. A made-up token gets 200. The strict server answers 401.
3. The built-in negative probes only remove credentials, so they pass here; this is a known gap, CS-GAP-008.
4. The reliable answer is a scenario with one step per bad token, which states the correct behaviour. This is the recommended approach, not a stopgap.
5. The scenario fails on the lenient route: expected 401, got 200. The strict route passes.
6. Two usual causes: the code verifies nothing beyond presence (verify signature, expiry and rights on every secured route, with one shared mechanism), or the spec promises more than the system does.
7. For managers: an access control that only looks for the presence of a token is not access control.
8. For DevOps: test refusal with a wrong token, an expired token and a token with too few rights; keep the tokens in the environment, not in files in the repository.
Show on screen: the security part of the spec, the two server answers, the scenario YAML, the command (clrsig run wrong-credentials.yaml --env clrsig/environments/conform-fail.yaml --spec specs/conform-fail.yaml), and the scenario output block, copied exactly from the card.
Name the check: none built in; this is the known gap CS-GAP-008. Say the clrsig version: v0.21.0.
Explain these words once: token (a secret string that proves who you are); expired (no longer valid because its time ran out); scope (what a token is allowed to do); scenario (a script of steps with your own checks, called assertions); exit code (0 clean, 1 a finding, 2 setup or spec broken).
Say what clrsig does not see here: the built-in probes do not send wrong, expired or under-privileged credentials; you write each case as a scenario step.
Safety line (if a write is shown): not needed, the scenario sends GET requests only.
Finish with three recap questions:
1. What are the three questions of authentication? (Is there a credential, is it genuine and current, is its owner allowed.)
2. Why do the built-in probes pass on this route? (They only remove credentials.)
3. What is the recommended check for this gap? (A scenario with one step per bad token.)
Tease the next video: AC-033 · Loose validation: enums, boundaries and unknown fields.
Do not: say "contract testing" alone; say clrsig "catches everything"; invent flags, IDs or numbers; read tables aloud; use any fact that is not in the card.