Skip to content

fix(auth): refuse an API token while its owner is disabled or deleted - #881

Merged
remyluslosius merged 1 commit into
mainfrom
fix/api-token-refused-while-owner-disabled
Sep 27, 2026
Merged

remyluslosius merged 1 commit into
mainfrom
fix/api-token-refused-while-owner-disabled

Conversation

@remyluslosius

Copy link
Copy Markdown
Contributor

v0.8 scope-freeze exception, approved 2026-09-25 (projects/openwatch/V0_8_0_READINESS). Fixes bugs/OW-071. No merge is authorized yet.

What was wrong

A disabled user's owk_ API token kept authenticating with its full role.

  • Who it affects: only admin and security_admin hold token:write, so this is the offboarding case for the highest-privilege accounts.
  • Why the workaround was partial: administrators can revoke any token, but the token list does not show a token's owner.

Change

This is P8 AC-95 only. AuthenticateToken joins the token's owner and refuses the token:

Owner state Result Audit reason on auth.login.failure
Disabled 401 api_token_owner_disabled
Soft-deleted 401 api_token_owner_deleted
None (created_by NULL) 401, fail closed api_token_ownerless
Active Authenticates as before
  • It is a check, not a revocation. A refusal writes nothing to the token row, last_used_at included. Re-enabling the owner restores the token, and a token revoked through DELETE /api/v1/tokens/{id} stays revoked.
  • Not included: P8's audit fields (service_token_effect, AC-97) and any change to the token list.

Contract, tests, docs

  • Spec: system-api-tokens 1.1.0. C-02 amended; C-04 and AC-06 added.
  • Audit contract: the three reasons are declared in audit/events.yaml, and the AC-80 vocabulary scan passes.
  • AC-06, end to end: covers disabled, soft-deleted, ownerless, the active control, and re-enable. It reads each request's own audit row by correlation id, and checks the token row was not written.
  • AC-02: its fixture now gives the token an active owner, because an ownerless token is refused by design.
  • Mutation checks, each turning an AC-06 case red:
    • allow a deleted owner;
    • allow a disabled owner;
    • allow an ownerless token;
    • stamp last_used_at on a refusal;
    • collapse the binder reason;
    • implement the gate as a revocation.
  • Docs:
    • the API guide's definition of an API token;
    • the incident runbook's credential table;
    • a CHANGELOG entry with an upgrade note: tokens with no owner stop authenticating, and the query to find them first is included.
  • make spec-check passes (100%).

Not in this PR

bugs/OW-079, filed: a database failure during token lookup answers 401 rather than 503. It predates this change and is in the backlog under the interruption rule.

CHANGELOG.md may conflict trivially with the other v0.8 exception PRs.

@github-actions github-actions Bot added documentation Improvements or additions to documentation size/L and removed documentation Improvements or additions to documentation labels Sep 26, 2026
A disabled user's owk_ token kept authenticating with its full role, so
disabling a departing administrator did not stop their automation
(bugs/OW-071). Only admin and security_admin hold token:write, so the
exposure was the highest-privilege accounts. The workaround was partial:
the token list does not show a token's owner.

AuthenticateToken now joins the token's owner and refuses the token when
the owner is disabled or soft-deleted, and always when the token has no
owner (fail closed). It is a check at authentication time, not a
revocation: a refusal writes nothing to the token row, so re-enabling the
owner restores the token, and a token revoked through Revoke stays
revoked. The binder records each refusal with its own declared reason:
api_token_owner_disabled, api_token_owner_deleted, api_token_ownerless.

This is P8 AC-95 only. P8's audit fields (service_token_effect) are not
included.

system-api-tokens 1.1.0: C-02 amended, C-04 and AC-06 added. AC-02's
fixture now gives its token an active owner, because an ownerless token
is refused by design. Mutations on each owner state, on ownerless
tokens, on stamping last_used_at on a refusal, on the binder reason, and
on implementing the gate as a revocation each turned an AC-06 case red.

Upgrade note in CHANGELOG: tokens with no owner stop authenticating;
the query to find them is included.

Approved as a v0.8 scope-freeze exception on 2026-09-25
(projects/openwatch/V0_8_0_READINESS). Adjacent finding filed, not
fixed: bugs/OW-079.
@remyluslosius
remyluslosius force-pushed the fix/api-token-refused-while-owner-disabled branch from d1a1eae to e1406a0 Compare September 27, 2026 00:32
@remyluslosius
remyluslosius merged commit fdd5754 into main Sep 27, 2026
14 checks passed
@remyluslosius
remyluslosius deleted the fix/api-token-refused-while-owner-disabled branch September 27, 2026 00:57
remyluslosius added a commit that referenced this pull request Sep 28, 2026
Stage 1 for the sixth 0.8.0 candidate, from main fc1117d. VERSION is
0.8.0-rc.6 in packaging/version.env, the README phrase and the newest
CHANGELOG heading; CODENAME stays Eyrie. The hygiene test binds the three.

The changelog section records rc.5 on facts: built, every machine gate
passed, assets published as a pre-release, no human verdict recorded for
its fleet checks, documentation review or release-captain signature, tag
and assets preserved. Since rc.5: #870 to #881, #883 and #882. The
[Unreleased] notes move into the rc.6 section unchanged.

Known limitations gain the two the readiness record lists as shipping with
v0.8: drift does not distinguish a corpus change from a host change (D-2
S-3, accepted 2026-09-26), and scan variable values are not type checked
(OW-080).

Next unused candidate number verified: no v0.8.0-rc.6 tag on the remote or
locally, and no release or draft of that name.

No tag, publication or attestation.
remyluslosius added a commit that referenced this pull request Sep 28, 2026
Stage 1 for the sixth 0.8.0 candidate, from main fc1117d. VERSION is
0.8.0-rc.6 in packaging/version.env, the README phrase and the newest
CHANGELOG heading; CODENAME stays Eyrie. The hygiene test binds the three.

The changelog section records rc.5 on facts: built, every machine gate
passed, assets published as a pre-release, no human verdict recorded for
its fleet checks, documentation review or release-captain signature, tag
and assets preserved. Since rc.5: #870 to #881, #883 and #882. The
[Unreleased] notes move into the rc.6 section unchanged.

Known limitations gain the two the readiness record lists as shipping with
v0.8: drift does not distinguish a corpus change from a host change (D-2
S-3, accepted 2026-09-26), and scan variable values are not type checked
(OW-080).

Next unused candidate number verified: no v0.8.0-rc.6 tag on the remote or
locally, and no release or draft of that name.

No tag, publication or attestation.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant