Skip to content

security(auth): SLM authority tokens honour a user revocation (#20446) - #20452

Merged
mrveiss merged 5 commits into
mainfrom
issue-20446-token-kinds
Nov 1, 2026
Merged

mrveiss merged 5 commits into
mainfrom
issue-20446-token-kinds

Conversation

@mrveiss

@mrveiss mrveiss commented Nov 1, 2026 •

Copy link
Copy Markdown
Owner

Refs #20446

Thinking Path

#20443 revokes a deactivated user's tokens with a marker, but SLM RS256 authority tokens never read it, so neither a deactivation nor a password change reaches them. A real signed token confirmed this.

What Changed

  • autobot-slm-backend/services/jwks_verifier.py: _rs256_user_is_revoked applies the shared marker check on the full-verify and cache-hit paths. A malformed iat is denied, and an unavailable store gives the shared 503.

  • Authority tokens read Redis, where the backend writes, not the SLM's own table. The only RS256 minting site is backend login and refresh, so these tokens name backend-database users. A token with no username or iat is refused in the verifier.

  • services/jwks_verifier_test.py: the fixture installs an empty marker store, because the existing tests had started reaching real Redis.

  • Device JWTs (maintainer decision): validate_device_jwt checks its owner's revocation marker through the shared check (services/device_owner_revocation.py). A missing or soft-deleted owner, or an empty user_id, is refused, the soft-deleted case going slightly beyond the decision. A store or lookup failure gives the shared 503; auth_middleware.py no longer turns that into a 401.

  • SLM API keys (maintainer decision): get_api_key_user refuses a key whose user is inactive or deleted. It still has no route callers, so this guards the first one to adopt it.

Cost per device request: one extra Redis read for the owner and one for the marker, with the owner cached for the existing 60-second device TTL, so a hard-deleted owner can pass for up to 60 seconds.

Verification

  • services/jwks_verifier_user_revocation_20446_test.py, with a real signed token: live user admitted; token before the marker refused; token after it, or another user's marker, admitted; cached claims refused; store down gives 503.

  • Tests use separate stores: a marker only in Redis refuses, and one only in the SLM table admits. Without in_redis=True 4 of 9 fail; without the username and iat check, 3 fail.

  • 62 passed on the verifier, revocation store and neighbouring SLM tests.

  • Device: device_owner_revocation_test.py 11 passed, 8 failing without the check; with the neighbouring device tests 164 passed. API keys: 5 new tests, 3 failing without the check; 36 passed with neighbours.

Not established:

Model Used

Claude Sonnet 5 for implementation, Claude Opus 5.5 for direction

🤖 Generated with Claude Code

@mrveiss mrveiss added this to the M2 - Company OS workflow-ready milestone Nov 1, 2026
@coderabbitai

coderabbitai Bot commented Nov 1, 2026 •

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 14 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration
Commits

Reviewing files that changed from the base of the PR and between 25ab945 and 6a0768e.

Files selected for processing: 9
  • autobot-backend/auth_middleware.py
  • autobot-backend/services/device_jwt.py
  • autobot-backend/services/device_jwt_test.py
  • autobot-backend/services/device_owner_revocation.py
  • autobot-backend/services/device_owner_revocation_test.py
  • autobot-backend/tests/integration/test_device_jwt_auth.py
  • autobot-slm-backend/services/auth.py
  • autobot-slm-backend/tests/api/test_api_key_owner_standing_20446.py
  • docs/developer/THREAT_MODEL.md
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@github-actions

github-actions Bot commented Nov 1, 2026

Copy link
Copy Markdown
Contributor

Notice: 29 open PRs — past the runaway threshold (25)

This is not a request to defer this PR. There is no cap on open PRs (#19397) -- nothing blocks opening or pushing a PR.

This notice only means the count is high enough to be worth a glance for a runaway — something opening PRs in a loop, or a merge pipeline that has stalled so nothing is draining.

Currently open:

If the queue is draining normally, ignore this. Otherwise:

  1. Check whether CI is dispatching at all — see the ci-dispatch-watchdog status on these PRs
  2. Approved PRs land through the merge train the coordinator sequences (merge commits, never squash) -- check the open chore(merge-train) PR is moving, not each PR on its own
  3. Look for a loop opening near-identical PRs

Warn-only runaway detector — .github/workflows/pr-queue-gate.yml. It never blocks a merge.

@github-actions

github-actions Bot commented Nov 1, 2026

Copy link
Copy Markdown
Contributor

✅ SSOT Configuration Compliance: Passing

🎉 No new hardcoded values of either class — ssot and other both block.

Known backlog in pipeline-scripts/hardcoded_values_baseline.txt is suppressed and tracked in #14371.

@mrveiss

mrveiss commented Nov 1, 2026

Copy link
Copy Markdown
Owner Author

Code review on PR #20452 (head b1fc3d1): approve. Read only. Authority tokens read the store backend writes, a token with no username or iat is refused, and a Redis outage fails closed with a 503, as on the backend. Lands after #20444.

@mrveiss

mrveiss commented Nov 1, 2026

Copy link
Copy Markdown
Owner Author

Code review on PR #20452 (head 693351c): approve, to land after #20444, whose deactivation writes the marker this reads. Delta since b1fc3d1, read only: the epoch is read fresh on each device call, only the owner lookup is cached 60s, and a store outage fails closed with a 503, for every device: a maintainer decision on #20443. Existing device rows with no owner were not checked.

@github-actions

github-actions Bot commented Nov 1, 2026

Copy link
Copy Markdown
Contributor

Auto-sync: merging main into issue-20446-token-kinds conflicts

The sync aborted the merge and pushed nothing. Conflicts are information, so it never resolves one itself. Below, for each conflicted file, are the commits that touched it on each side since the merge base f88cd3756a. Merge main in yourself and push; the label clears on the first run that finds this branch 0 behind.

repo_tests/frontend_url_served_by_19326_test.py

side commit subject issue refs
main 8e17b7290 fix(train): reach floors return to mid-window on the merged tree (#20444) #20444
this branch 693351c46 chore(guards): re-pin the reach floors the pre-push gate reported stale (#20452) #20452

mrveiss added a commit that referenced this pull request Nov 1, 2026
@mrveiss
mrveiss merged commit 9499e06 into main Nov 1, 2026
5 checks passed
@mrveiss
mrveiss deleted the issue-20446-token-kinds branch November 1, 2026 22:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

phase:M2.1 Company and company boundaries

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant