Repository navigation
Security: app session minting is opt-in; revoke/rotate end minted sessions (v0.2.1) - #4
Merged
Merged
Conversation
…minted sessions (0.2.1)
0.2.0 let every linked app with trust_email (the default) mint full cvs_ sessions with
POST /v1/apps/self/users/{subject}/sessions, those sessions could create never-expiring
access tokens, and apps revoke / apps rotate only touched the apps row, so minted
credentials survived incident response.
- migration 0007: apps.allow_sessions (default false), sessions.created_by_app +
max_expires_at, access_tokens.created_by_app; best-effort backfill of minted sessions
from app.user.session audit rows
- mint requires allow_sessions AND trust_email (403 sessions_not_allowed), re-checked under
a share lock on the app row; minted sessions are tagged and capped at
limits.app_session_ttl_hours (default 720, non-sliding)
- tokens created from a minted session copy created_by_app
- apps revoke / apps rotate delete tagged sessions and revoke tagged tokens, print and audit
the counts; apps rotate --keep-sessions opts out
- CLI: apps create --allow-sessions, apps set/update --allow-sessions, apps show, id-or-name
app references, apps list shows minting status and minted credentials
- doctor lists apps that may mint and warns on misconfiguration
- docs, openapi, CHANGELOG 0.2.1 (Security, Breaking), version 0.2.1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes a HIGH-severity issue in the 0.2.0 app-session endpoint (
POST /v1/apps/self/users/{subject}/sessions, #2).Problem. Any linked app with
trust_email(the default, so every existing app key) could mint fullcvs_sessions for anyone it could provision or link by email. Those sessions could create never-expiring access tokens.apps revokeandapps rotateonly touched theappsrow, so minted sessions and their tokens survived incident response.Fix
Migration
0007_app_sessions_opt_in(13 migrations total) adds:apps.allow_sessions boolean NOT NULL DEFAULT false;sessions.created_by_appandsessions.max_expires_at;access_tokens.created_by_app.It also tags pre-0.2.1 minted sessions, best effort, from the
app.user.sessionaudit rows.Minting needs
allow_sessions AND trust_email; otherwise it returns403 sessions_not_allowed(ortrust_email_required). The policy is re-checked in the mint transaction under aFOR SHARElock on the live app row and key, so a concurrent revoke or rotate either sees the new session or the mint fails with 401.Tagging. Minted sessions carry
created_by_app.POST /v1/tokenscopies the session'screated_by_apponto the token, underFOR SHAREon the session row.Revocation.
apps revokedeletes the app's tagged sessions and revokes its tagged tokens. It does this even when the app is already revoked.apps rotatedoes the same by default;--keep-sessionsopts out.sessions_ended/tokens_revoked).TTL cap.
limits.app_session_ttl_hours(default 720,0= no cap) is a non-sliding cap on minted sessions.CLI
apps create --allow-sessionsapps set|update <app> --allow-sessions true|falseapps show <app>apps listshows whether each app can mint, plus its live minted sessions/tokens.doctor lists the apps that can mint, warns about
allow_sessionswithouttrust_email, and warns when[[delegated_sign_in]]is configured but no app can mint.API and docs.
stats→app.allow_sessions;/v1/infolimits →app_session_ttl_hours.## 0.2.1has Security and Breaking sections. Workspace version bumped to 0.2.1.Breaking. Existing apps can't mint sessions until an operator opts them in with
canvas-cloud apps set <app> --allow-sessions true.Tests (native PostgreSQL)
allow_sessions, including fortrust_emailapps, forallow_sessionswithouttrust_email, and after the flag is turned off.allow_sessionsand tags the session; the TTL cap applies and the session doesn't slide past it.--keep-sessionskeeps minted sessions.updatealias, show, list, rotate, revoke, audit counts, and name ambiguity.allow_sessionsto false and backfills the minted session.