security: the bridge SSO session cookie is the bare AID, unsigned — anyone who knows a member's public AID can take the silent hop as them #1966

Closed
opened 2026-09-28 16:15:32 +00:00 by matou-build-agent · 1 comment

The fault

The bridge's sign-in session cookie carries the member's AID as its value, unsigned:

// internal/idp/signin.go, setSessionCookie
Name:     sessionCookieName,   // "idss_idp_session"
Value:    aid,                 // the bare AID. Nothing signs it.
HttpOnly: true, Secure: true, SameSite: Lax

and the silent cross-client SSO hop reads it straight back (completeFromSession):

  1. heldCredential(c.Value) — is that AID in held and unexpired (12 h)?
  2. verifierFor(identity).IsIssued(...) — does its membership credential still stand on the community's ledger?
  3. authRequestForLogin(id) — is there a live auth request?
  4. completeLogin(id, identity) → the auth request is now authenticated as that AID.

Every one of those checks passes for an attacker who simply asserts someone else's AID. No step involves a secret.

An AID is a public identifier. It is on the community ledger, in every credential, on the Members roster, in the sign-in QR, and in the puaid= parameter the panel's own transport reads today. Knowing one is not a compromise — it is the normal state of affairs.

HttpOnly, Secure and SameSite=Lax do not help here. They stop a script reading the cookie and stop a cross-site request carrying it; they do nothing against an attacker who sets the cookie in their own client.

What it costs

Within the 12 h after any member last signed in, anyone who knows their AID can:

  1. begin a sign-in at any service the bridge fronts (Files, chat, code, the control panel — whatever is wired);
  2. send Cookie: idss_idp_session=<their AID>;
  3. take the silent hop and receive tokens as that member.

For an ordinary member that is their files and their chat. For a steward it is the control panel. It needs no phone, no words, no credential and no network position — only a public string and a live held entry.

The control panel's own session gets this right (internal/controlapi/session.go): a stateless HMAC-signed cookie over {identity, expiry}, with hmac.Equal on every read, because "it is the one place the session's trust is." The bridge, one hop upstream, has no equivalent.

What to build

The cookie must carry something unforgeable. Two honest shapes, and a recommendation:

  • An opaque, high-entropy session id (recommended). held is already a server-side map; key it by a random id minted at completeLogin rather than by the AID, and let the cookie carry only that id. The AID is then never an input, and the bridge gains real per-session revocation for free — which is what #1935's panel-session epoch had to invent separately, and what sign-out (#1713, #1363) has never truly had.
  • An HMAC-signed value, the shape controlapi/session.go already ships. Smaller diff, one more place a secret must be provisioned and rotated, and it still cannot revoke a single session before its expiry.

Either way: the AID alone must never again be sufficient, and an unrecognised or unverifiable cookie must fall through to the sign-in form exactly as today (fail closed, no error page).

Acceptance criteria

  • Given a member who signed in less than 12 h ago, when a request presents idss_idp_session set to that member's AID, then the silent hop is REFUSED and the sign-in form is rendered.
  • Given a genuine browser that signed in, when it hops to another service, then the silent SSO hop still completes exactly as today — no re-prompt, no behaviour change for a real session.
  • Given a tampered, truncated, or unknown cookie value, then it fails closed to the sign-in form — never an error page, never a partial session.
  • Given a revoked membership, then the ledger re-walk still refuses the hop (ADR 0196's amendment, #1524, unchanged).
  • Given sign-out, then the session cannot be resumed by replaying the old cookie value.
  • Given both doors (the browser verify step and the app door's status route), then both mint the new form — an app-door sign-in still earns the same cross-client SSO session.
  • Proven at internal/idp's existing seam, with a forged-cookie case that is red before the fix.

Blocked by

  • None.

Notes

  • Found while working #1961: option B needs the door to bind a freshly-landed panel to "the sign-in it just completed", and the only session identifier the door had was this cookie. #1961 has since been ruled to use a minted single-use handover capability instead of this cookie, so it does not depend on this ticket — but the hole it exposed is real on its own, independent of the panel unlock, and predates it.
  • Related but distinct: #1941 (a forgeable identity header on the private network). Same family — an identifier treated as an authenticator — different surface.
  • ADR 0196 should record the change; the cookie's shape is stated there.
## The fault The bridge's sign-in session cookie carries **the member's AID as its value, unsigned**: ```go // internal/idp/signin.go, setSessionCookie Name: sessionCookieName, // "idss_idp_session" Value: aid, // the bare AID. Nothing signs it. HttpOnly: true, Secure: true, SameSite: Lax ``` and the silent cross-client SSO hop reads it straight back (`completeFromSession`): 1. `heldCredential(c.Value)` — is that AID in `held` and unexpired (12 h)? 2. `verifierFor(identity).IsIssued(...)` — does its membership credential still stand on the community's ledger? 3. `authRequestForLogin(id)` — is there a live auth request? 4. `completeLogin(id, identity)` → the auth request is now authenticated **as that AID**. Every one of those checks passes for an attacker who simply *asserts* someone else's AID. **No step involves a secret.** An AID is a public identifier. It is on the community ledger, in every credential, on the Members roster, in the sign-in QR, and in the `puaid=` parameter the panel's own transport reads today. Knowing one is not a compromise — it is the normal state of affairs. `HttpOnly`, `Secure` and `SameSite=Lax` do not help here. They stop a script reading the cookie and stop a cross-site request carrying it; they do nothing against an attacker who sets the cookie in their own client. ## What it costs Within the 12 h after any member last signed in, anyone who knows their AID can: 1. begin a sign-in at any service the bridge fronts (Files, chat, code, the control panel — whatever is wired); 2. send `Cookie: idss_idp_session=<their AID>`; 3. take the silent hop and receive tokens **as that member**. For an ordinary member that is their files and their chat. For a steward it is the control panel. It needs no phone, no words, no credential and no network position — only a public string and a live `held` entry. The control panel's own session gets this right (`internal/controlapi/session.go`): a stateless **HMAC-signed** cookie over `{identity, expiry}`, with `hmac.Equal` on every read, because "it is the one place the session's trust is." The bridge, one hop upstream, has no equivalent. ## What to build The cookie must carry something **unforgeable**. Two honest shapes, and a recommendation: - **An opaque, high-entropy session id** (recommended). `held` is already a server-side map; key it by a random id minted at `completeLogin` rather than by the AID, and let the cookie carry only that id. The AID is then never an input, and the bridge gains real per-session revocation for free — which is what `#1935`'s panel-session epoch had to invent separately, and what sign-out (#1713, #1363) has never truly had. - **An HMAC-signed value**, the shape `controlapi/session.go` already ships. Smaller diff, one more place a secret must be provisioned and rotated, and it still cannot revoke a single session before its expiry. Either way: the AID alone must never again be sufficient, and an unrecognised or unverifiable cookie must fall through to the sign-in form exactly as today (fail closed, no error page). ## Acceptance criteria - [ ] **Given** a member who signed in less than 12 h ago, **when** a request presents `idss_idp_session` set to that member's AID, **then** the silent hop is REFUSED and the sign-in form is rendered. - [ ] **Given** a genuine browser that signed in, **when** it hops to another service, **then** the silent SSO hop still completes exactly as today — no re-prompt, no behaviour change for a real session. - [ ] **Given** a tampered, truncated, or unknown cookie value, **then** it fails closed to the sign-in form — never an error page, never a partial session. - [ ] **Given** a revoked membership, **then** the ledger re-walk still refuses the hop (ADR 0196's amendment, #1524, unchanged). - [ ] **Given** sign-out, **then** the session cannot be resumed by replaying the old cookie value. - [ ] **Given** both doors (the browser verify step and the app door's status route), **then** both mint the new form — an app-door sign-in still earns the same cross-client SSO session. - [ ] Proven at `internal/idp`'s existing seam, with a forged-cookie case that is red before the fix. ## Blocked by - None. ## Notes - Found while working #1961: option B needs the door to bind a freshly-landed panel to "the sign-in it just completed", and the only session identifier the door had was this cookie. #1961 has since been ruled to use a minted single-use handover capability *instead of* this cookie, so it does **not** depend on this ticket — but the hole it exposed is real on its own, independent of the panel unlock, and predates it. - Related but distinct: #1941 (a forgeable identity header on the private network). Same family — an identifier treated as an authenticator — different surface. - ADR 0196 should record the change; the cookie's shape is stated there.
Author
Member

Close-report — #1966 (Ruled by agent under ADR 0174 — two-way, veto anytime)

What landed (main @ 2669b857): the bridge idss_idp_session cookie no longer carries the bare AID. Both doors now mint a 256-bit opaque session id (store.sessions: id → AID, 12 h, live-session state cleared on restart, internal/idp/storage.go) and the cookie carries only the id. completeFromSession resolves the id server-side (sessionAID) before the existing held-cache lookup and ADR 0196 ledger re-walk; an unknown/tampered/truncated/expired id fails closed to the sign-in form. Sign-out destroys the id (endSessionByCookie + a per-AID sweep in endSession, signout.go), so a captured cookie value cannot be replayed once its owner signs out.

Acceptance criteria

  • Cookie set to a member's AID → silent hop REFUSED, sign-in form rendered — TestSeam_ForgedAIDCookie_RefusedToSignIn (RED before the fix, green after).
  • Genuine browser hop still completes with no re-prompt — TestSeam_SilentSSO_AcrossClients unchanged & green.
  • Tampered/truncated/unknown cookie → fails closed, never an error page — TestSeam_TamperedSessionCookie_FailsClosedToSignIn.
  • Revoked membership → ledger re-walk still refuses (ADR 0196 amendment / #1524, unchanged) — TestSeam_SilentHopAfterRevoke_FallsToSignIn green.
  • Sign-out → old cookie value cannot be replayed — TestSeam_SignOut_OldSessionCookieCannotBeReplayed + TestSeam_IDIPSignOut_ValidRedirect_EndsBridgeSession.
  • Both doors mint the new form; app-door sign-in earns the same cross-client SSO session — TestSeam_AppDoorSession_IsOpaqueAndCompletesSilentHop.
  • Proven at internal/idp's existing seam with a forged-cookie case red before the fix.

Proof: full go test ./internal/idp/ green; go build ./..., go vet, gofmt -l, golangci-lint run ./internal/idp/ (0 issues) all clean. New seam file internal/idp/signin_session_cookie_seam_test.go; keri_verifier_test.go's old cookie == AID assertion updated to the opaque shape.

Docs: ADR 0196 amended (Amendment 2026-09-28 — the session cookie carries an OPAQUE id, not the AID); STATUS.md milestone log updated in the same commit.

Scope / not done here: per-service admin state and #1961's minted handover capability are their own tickets and untouched; the held map stays AID-keyed for the device-code/refresh paths (op supplies the subject there — no cookie, not forgeable), so only the cookie's key changed.

**Close-report — #1966 (Ruled by agent under ADR 0174 — two-way, veto anytime)** **What landed** (`main` @ `2669b857`): the bridge `idss_idp_session` cookie no longer carries the bare AID. Both doors now mint a 256-bit opaque session id (`store.sessions`: id → AID, 12 h, live-session state cleared on restart, `internal/idp/storage.go`) and the cookie carries only the id. `completeFromSession` resolves the id server-side (`sessionAID`) before the existing held-cache lookup and ADR 0196 ledger re-walk; an unknown/tampered/truncated/expired id **fails closed** to the sign-in form. Sign-out destroys the id (`endSessionByCookie` + a per-AID sweep in `endSession`, `signout.go`), so a captured cookie value cannot be replayed once its owner signs out. **Acceptance criteria** - [x] Cookie set to a member's AID → silent hop REFUSED, sign-in form rendered — `TestSeam_ForgedAIDCookie_RefusedToSignIn` (RED before the fix, green after). - [x] Genuine browser hop still completes with no re-prompt — `TestSeam_SilentSSO_AcrossClients` unchanged & green. - [x] Tampered/truncated/unknown cookie → fails closed, never an error page — `TestSeam_TamperedSessionCookie_FailsClosedToSignIn`. - [x] Revoked membership → ledger re-walk still refuses (ADR 0196 amendment / #1524, unchanged) — `TestSeam_SilentHopAfterRevoke_FallsToSignIn` green. - [x] Sign-out → old cookie value cannot be replayed — `TestSeam_SignOut_OldSessionCookieCannotBeReplayed` + `TestSeam_IDIPSignOut_ValidRedirect_EndsBridgeSession`. - [x] Both doors mint the new form; app-door sign-in earns the same cross-client SSO session — `TestSeam_AppDoorSession_IsOpaqueAndCompletesSilentHop`. - [x] Proven at `internal/idp`'s existing seam with a forged-cookie case red before the fix. **Proof**: full `go test ./internal/idp/` green; `go build ./...`, `go vet`, `gofmt -l`, `golangci-lint run ./internal/idp/` (0 issues) all clean. New seam file `internal/idp/signin_session_cookie_seam_test.go`; `keri_verifier_test.go`'s old `cookie == AID` assertion updated to the opaque shape. **Docs**: ADR 0196 amended (`Amendment 2026-09-28 — the session cookie carries an OPAQUE id, not the AID`); STATUS.md milestone log updated in the same commit. **Scope / not done here**: per-service admin state and #1961's minted handover capability are their own tickets and untouched; the `held` map stays AID-keyed for the device-code/refresh paths (op supplies the subject there — no cookie, not forgeable), so only the cookie's key changed.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Matou/idss#1966
No description provided.