oficina / home Public

Straight in: Fable's review findings 1, 3, 5 and 6

1. The slice 1 spec and exchange.go record the accepted limits of Paul's
   ruling, wider than "signs the victim in to their own account": any
   site can sign a visitor in to any registered app with no click; any
   registered app learns a visitor's subject; a junk /authorize
   overwrites an in-flight intent; session presence is visible to
   registered apps by design.
3. The minting GET refuses a prefetch or prerender (Sec-Purpose,
   Purpose), and when Sec-Fetch headers are present requires
   Sec-Fetch-Mode navigate and Sec-Fetch-Dest document
   (mintingNavigation; logged as not_navigation).
   TestIDStraightInMintsOnlyForANavigation.
5. Spec status line reworded; one sentence that POST /authorize/resume
   stays behind CSRF and the GET mint is deliberately outside it; the
   slice 1 Home plan's Continue page marked superseded.
6. TestIDStraightInForeignNonceRefusedAtFinish: an assertion minted by
   the straight-in GET for another browser's nonce, or a made-up one, is
   refused at the app's finish.

Finding 4 (Callback uses Receive, not ReceivePending) is pre-existing and
tracked in discussion #143, not fixed here.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
claude agent, operated by paul@keymail.dev 9dbc8e5a816d10675cb59ec170bec3c736d6ae61 parent 0a63310
5 files changed, +150 −12
  • docs/superpowers/plans/2026-11-13-oficina-id-slice1-home.md +3 −1
  • docs/superpowers/specs/2026-11-13-oficina-id-slice-1.md +10 −2
  • internal/home/exchange.go +43 −9
  • internal/home/handoff_failure.go +3 −0
  • internal/home/id_exchange_test.go +91 −0

CI passed — run details

CI log
amadan: .amadan/timeout: this job's budget is 20m0s (this runner allows up to 30m0s)
=== vet ===
CGO_ENABLED=0 go vet ./...
CGO_ENABLED=0 go vet -tags browser ./internal/home/
cd handoff && CGO_ENABLED=0 go vet ./...
cd roster && CGO_ENABLED=0 go vet ./...
cd dashboard && CGO_ENABLED=0 go vet ./...
cd connect && CGO_ENABLED=0 go vet ./...
cd teammode && CGO_ENABLED=0 go vet ./...
=== fmt ===
=== build ===
CGO_ENABLED=0 go build ./...
CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build ./cmd/home ./cmd/oficina ./internal/operatorlaunch
cd handoff && CGO_ENABLED=0 go build ./...
cd roster && CGO_ENABLED=0 go build ./...
cd dashboard && CGO_ENABLED=0 go build ./...
cd connect && CGO_ENABLED=0 go build ./...
cd teammode && CGO_ENABLED=0 go build ./...
=== go-test ===
CGO_ENABLED=0 go test -count=1 ./...
?   	amadan.net/oficina/home/cmd/home	[no test files]
ok  	amadan.net/oficina/home/cmd/home-placeholder	0.725s
?   	amadan.net/oficina/home/cmd/oficina	[no test files]
ok  	amadan.net/oficina/home/internal/guardstest	0.151s
ok  	amadan.net/oficina/home/internal/home	56.375s
ok  	amadan.net/oficina/home/internal/home/directorydata	1.382s
ok  	amadan.net/oficina/home/internal/home/logtest	0.004s
ok  	amadan.net/oficina/home/internal/home/seal	0.002s
ok  	amadan.net/oficina/home/internal/home/sealtest	0.002s
ok  	amadan.net/oficina/home/internal/home/wisp	0.046s
ok  	amadan.net/oficina/home/internal/operator	6.476s
ok  	amadan.net/oficina/home/internal/operatorlaunch	4.113s
ok  	amadan.net/oficina/home/internal/provisioner	49.268s
cd handoff && CGO_ENABLED=0 go test -count=1 ./...
ok  	amadan.net/oficina/home/handoff	0.651s
ok  	amadan.net/oficina/home/handoff/seal	0.002s
cd roster && CGO_ENABLED=0 go test -count=1 ./...
ok  	amadan.net/oficina/home/roster	5.124s
cd dashboard && CGO_ENABLED=0 go test ./...
ok  	amadan.net/oficina/home/dashboard	(cached)
cd connect && CGO_ENABLED=0 go test -count=1 ./...
ok  	amadan.net/oficina/home/connect	1.403s
ok  	amadan.net/oficina/home/connect/linkstore	0.402s
cd teammode && CGO_ENABLED=0 go test -count=1 ./...
ok  	amadan.net/oficina/home/teammode	0.099s
?   	amadan.net/oficina/home/teammode/teammodetest	[no test files]
=== race ===
go test -race -count=1 ./internal/home/ ./internal/operator/ ./internal/operatorlaunch/ ./internal/home/directorydata/
ok  	amadan.net/oficina/home/internal/home	336.943s
ok  	amadan.net/oficina/home/internal/operator	82.513s
ok  	amadan.net/oficina/home/internal/operatorlaunch	22.389s
ok  	amadan.net/oficina/home/internal/home/directorydata	23.587s
ok  	amadan.net/oficina/home/internal/provisioner	400.146s
cd handoff && CGO_ENABLED=1 go test -race -count=1 ./...
ok  	amadan.net/oficina/home/handoff	12.883s
ok  	amadan.net/oficina/home/handoff/seal	1.015s
cd roster && CGO_ENABLED=1 go test -race -count=1 ./...
ok  	amadan.net/oficina/home/roster	6.953s
cd dashboard && CGO_ENABLED=1 go test -race -count=1 ./...
ok  	amadan.net/oficina/home/dashboard	1.064s
cd connect && CGO_ENABLED=1 go test -race -count=1 ./...
ok  	amadan.net/oficina/home/connect	6.232s
ok  	amadan.net/oficina/home/connect/linkstore	6.274s
cd teammode && CGO_ENABLED=1 go test -race -count=1 ./...
ok  	amadan.net/oficina/home/teammode	1.940s
?   	amadan.net/oficina/home/teammode/teammodetest	[no test files]
diff --git a/docs/superpowers/plans/2026-11-13-oficina-id-slice1-home.md b/docs/superpowers/plans/2026-11-13-oficina-id-slice1-home.md
index 8e07292..3603dae 100644
--- a/docs/superpowers/plans/2026-11-13-oficina-id-slice1-home.md
+++ b/docs/superpowers/plans/2026-11-13-oficina-id-slice1-home.md
@@ -6,7 +6,9 @@ no deployment or merge. Equipo and changes to its connect adapter are part B.
## Tasks
1. [x] Require a new authentication gesture for `max_age=300`; add a protected,
- fixed-label Continue page for existing sessions. Files: `exchange.go`,
+ fixed-label Continue page for existing sessions. (The Continue page is
+ superseded 2026-11-20 by Paul's straight-in ruling: an existing session
+ now mints on the GET; slice 1 spec, Assertion and browser exchange.) Files: `exchange.go`,
`signin.go`, `app.go`, templates, assertion tests. Preserve the closed
consumer manifest and 120-second P-256 assertions.
2. [x] Add browser-bound, five-minute, single-use direct passkey sign-in and
diff --git a/docs/superpowers/specs/2026-11-13-oficina-id-slice-1.md b/docs/superpowers/specs/2026-11-13-oficina-id-slice-1.md
index 45d59a1..3bf1fc3 100644
--- a/docs/superpowers/specs/2026-11-13-oficina-id-slice-1.md
+++ b/docs/superpowers/specs/2026-11-13-oficina-id-slice-1.md
@@ -1,6 +1,6 @@
# 🤖 Oficina ID: slice 1
-Status: revised design, 2026-11-13, applying Paul's rulings and Fable's READY AFTER FIXES review as supplied by Paul. Independently reviewed after these fixes by GPT-6 Astra (`gpt-6-astra`): acceptable as a spec, no blocking findings. Author: Codex. No implementation, deployment or merge approval. Amended 2026-11-20 by Paul's web straight-in ruling (Assertion and browser exchange, step 2), built on Home `feat/web-straight-in`.
+Status: revised design, 2026-11-13, applying Paul's rulings and Fable's READY AFTER FIXES review as supplied by Paul. Independently reviewed after these fixes by GPT-6 Astra (`gpt-6-astra`): acceptable as a spec, no blocking findings. Author: Codex. Slice 1 was implemented and merged on Home `main` under Paul's approval of 2026-11-13. Amended 2026-11-20 by Paul's web straight-in ruling (Assertion and browser exchange, step 2), built on Home `feat/web-straight-in`, reviewed by Claude Fable (APPROVE, low findings applied); that branch is not yet merged or deployed.
## Decision and boundary
@@ -59,7 +59,15 @@ No email, role, grants, document list, encryption keys or authentication-strengt
3. Accept only a bounded form POST with exact issuer `Origin`. Verify signature, issuer, audience, types and times. Before storing a receipt, require its signed nonce to match a live pending transaction; check and insert atomically. Reserve `(iss,jti)` uniquely so repeated callbacks refuse. Unknown nonces and storage failures store nothing.
4. Store a sealed, expiring inbox receipt, then redirect to `/auth/finish`. Its top-level GET receives the original SameSite=Lax cookie. Recheck the browser secret, nonce, expiry and account binding. Consume the pending/inbox proof, record replay use, resolve the current mapping/admission and mint the session atomically. Preserve the clock watermark and replay retention through expiry plus thirty seconds across restarts. Never mint at the cross-site POST.
-**Straight in on the web (Paul's ruling, 2026-11-20).** Someone already signed in to id.* who taps "Continue with Oficina ID" in an app goes straight into the app, as the native apps already do (Paul's 11-19 "one ID = straight in", native spec §9). `GET /authorize/resume` mints and renders the form-POST delivery itself (auto-submit, with the Continue button for scripts off); the "Continue to the app" page is gone. Safety (Fable's review of connect, 2026-11-20): a third-party-triggered GET to the app's `/signin/oficina` or `/auth/start`, or to `/authorize`, binds the exchange to the victim's own pending cookie, the victim's own id.* session and an assertion posted from the victim's own browser, so no attacker identity can be planted; the worst case is signing the victim in to their own account. Unchanged: `max_age=300` (linking, and every step-up) still sends a standing session to the door for a new authentication gesture before anything is minted (Linking and unlinking, below); without an id.* session the request still lands on the sign-in door; the assertion still never appears in a URL or a log.
+**Straight in on the web (Paul's ruling, 2026-11-20).** Someone already signed in to id.* who taps "Continue with Oficina ID" in an app goes straight into the app, as the native apps already do (Paul's 11-19 "one ID = straight in", native spec §9). `GET /authorize/resume` mints and renders the form-POST delivery itself (auto-submit, with the Continue button for scripts off); the "Continue to the app" page is gone. Safety (Fable's review of connect, 2026-11-20): a third-party-triggered GET to the app's `/signin/oficina` or `/auth/start`, or to `/authorize`, binds the exchange to the victim's own pending cookie, the victim's own id.* session and an assertion posted from the victim's own browser, so no attacker identity can be planted. Only a top-level navigation mints: the GET refuses `Sec-Purpose`/`Purpose` prefetch or prerender, and when `Sec-Fetch-*` headers are present requires `Sec-Fetch-Mode: navigate` and `Sec-Fetch-Dest: document`. The minting GET is deliberately outside the CSRF check (it is a GET); `POST /authorize/resume`, kept for a Continue page open in a tab, stays behind it.
+
+**Accepted limits of Paul's ruling** (Fable's review of `feat/web-straight-in`, 2026-11-20). "The worst case is signing the victim in to their own account" is too narrow; these are accepted:
+- (a) any site can sign a visitor who has an id.* session in to any registered consumer with no click; whether that first visit creates app-side state depends on each app's `Complete`;
+- (b) any registered consumer origin, or script running on one, learns a visitor's Oficina subject with no id.* interaction;
+- (c) a junk-nonce `/authorize` overwrites the victim's in-flight intent cookie (and, through the app's start, its inbox cookie), breaking a sign-in in progress;
+- (d) whether a browser has an id.* session (it leaves id.* at once, or stays on the door) is visible to registered consumers by design; no cross-site read of it was found.
+
+Unchanged: `max_age=300` (linking, and every step-up) still sends a standing session to the door for a new authentication gesture before anything is minted (Linking and unlinking, below); without an id.* session the request still lands on the sign-in door; the assertion still never appears in a URL or a log.
The final transaction boundary is a required adapter change: today's `handoff.Finish` commits before `Complete`. Do not leave a consumed proof in memory that can mint after unlink/relink. Reject swapped browsers, purposes or accounts; an assertion cannot silently replace another signed-in account. Only the callback bypasses ordinary cross-origin request-forgery checks. Bound pending/inbox rows and prune them; keep local return queries app-side.
diff --git a/internal/home/exchange.go b/internal/home/exchange.go
index e867848..9f961ff 100644
--- a/internal/home/exchange.go
+++ b/internal/home/exchange.go
@@ -76,6 +76,10 @@ func (a *App) handleAssertion(w http.ResponseWriter, r *http.Request) {
a.failAssertion(w, r, assertionQuery)
return
}
+ if r.Method == http.MethodGet && !mintingNavigation(r) {
+ a.failAssertion(w, r, assertionNotNavigation)
+ return
+ }
now := time.Now()
intent, ok := a.readAssertionIntent(r, now)
if !ok {
@@ -123,16 +127,23 @@ func (a *App) handleAssertion(w http.ResponseWriter, r *http.Request) {
}
// Straight in (Paul, 2026-11-20; slice 1 spec, "Assertion and browser
// exchange" step 2): someone already signed in to id.* goes straight
- // to the app. The GET mints, with no "Continue to the app" page. A
- // GET anyone can trigger is safe here because everything it binds to
- // is the victim's own: the intent cookie this browser was given by
+ // to the app. The GET mints, with no "Continue to the app" page, and
+ // is deliberately outside csrf.Protect's reach (a GET); only a
+ // top-level navigation mints (mintingNavigation). Everything it binds
+ // to is the victim's own: the intent cookie this browser was given by
// /authorize, this browser's id.* session, and the delivery, a form
- // POST from this browser to the consumer, whose callback matches the
- // nonce against that browser's own pending cookie. The worst a
- // third-party GET can do is sign the victim in to their own account.
- // A step-up or a link (max_age) never reaches here on a standing
- // session: the check above sent it to the door for a new gesture.
- // The POST is kept for a Continue page still open in a tab.
+ // POST from this browser to the consumer, whose finish matches the
+ // nonce against that browser's own pending cookie, so no attacker
+ // identity can be planted. The accepted limits of Paul's ruling are
+ // wider than "signs the victim in to their own account" and are listed
+ // in the slice 1 spec (Assertion and browser exchange): any site can
+ // sign a victim in to any registered app with no click; any registered
+ // app learns a visitor's subject with no id.* interaction; a junk
+ // /authorize overwrites an in-flight intent; and session presence is
+ // visible to registered apps. A step-up or a link (max_age) never
+ // reaches here on a standing session: the check above sent it to the
+ // door for a new gesture. The POST, behind csrf.Protect, is kept for a
+ // Continue page still open in a tab.
id, err := assertion.RandomID()
if err != nil {
a.failAssertion(w, r, assertionRandom)
@@ -163,3 +174,26 @@ func (a *App) handleAssertion(w http.ResponseWriter, r *http.Request) {
func keymailWithoutGesture(session sessions.Session) bool {
return session.Method == string(signin.MethodKeymail) && session.AuthTime.IsZero()
}
+
+// mintingNavigation reports whether a GET of /authorize/resume may mint:
+// a top-level navigation, never a prefetch or prerender, and never a
+// fetch, an image or a frame (defence in depth for straight in, Fable's
+// review of 2026-11-20). A browser that sends no Sec-Fetch headers is
+// judged on Sec-Purpose and Purpose alone; one that sends any must say
+// navigate and document.
+func mintingNavigation(r *http.Request) bool {
+ for _, name := range []string{"Sec-Purpose", "Purpose", "X-Purpose", "X-Moz"} {
+ for _, v := range r.Header.Values(name) {
+ v = strings.ToLower(v)
+ if strings.Contains(v, "prefetch") || strings.Contains(v, "prerender") || strings.Contains(v, "preview") {
+ return false
+ }
+ }
+ }
+ _, mode := r.Header["Sec-Fetch-Mode"]
+ _, dest := r.Header["Sec-Fetch-Dest"]
+ if mode || dest {
+ return r.Header.Get("Sec-Fetch-Mode") == "navigate" && r.Header.Get("Sec-Fetch-Dest") == "document"
+ }
+ return true
+}
diff --git a/internal/home/handoff_failure.go b/internal/home/handoff_failure.go
index 85a4fc6..40a75ed 100644
--- a/internal/home/handoff_failure.go
+++ b/internal/home/handoff_failure.go
@@ -20,6 +20,7 @@ const (
assertionSubject
assertionRandom
assertionSign
+ assertionNotNavigation
)
// Only this fixed vocabulary reaches logs; no request or error is accepted.
@@ -48,6 +49,8 @@ func (a *App) failAssertion(w http.ResponseWriter, r *http.Request, code handoff
reason = "random_id"
case assertionSign:
reason = "signing"
+ case assertionNotNavigation:
+ reason = "not_navigation"
}
a.logger.Warn("home handoff failed", "stage", stage, "reason", reason)
a.renderHandoffFailure(w, r, http.StatusBadRequest)
diff --git a/internal/home/id_exchange_test.go b/internal/home/id_exchange_test.go
index 1679e8d..83f99b4 100644
--- a/internal/home/id_exchange_test.go
+++ b/internal/home/id_exchange_test.go
@@ -91,6 +91,97 @@ func TestIDStraightIn(t *testing.T) {
}
}
+// TestIDStraightInForeignNonceRefusedAtFinish: an assertion the
+// straight-in GET minted for a nonce that is not this browser's pending
+// one (another browser's, or one made up and sent to /authorize) never
+// signs this browser in at the app: the app's finish refuses it.
+func TestIDStraightInForeignNonceRefusedAtFinish(t *testing.T) {
+ p := newExchangePair(t)
+ session := signInFully(t, p.credential, sealtest.CanaryAddress)
+ pending, _ := p.start(t)
+ _, otherIntent := p.start(t)
+ junk := exchangeRequest(p.credential.App, "GET", Origin+"/authorize?consumer=directory&nonce="+base64.RawURLEncoding.EncodeToString(make([]byte, 16)), "", nil, session)
+ if junk.Code != http.StatusSeeOther {
+ t.Fatal("junk authorize", junk.Code)
+ }
+ for name, intent := range map[string]*http.Cookie{"another browser's nonce": otherIntent, "a made-up nonce": namedCookie(t, junk, assertionIntentCookie)} {
+ t.Run(name, func(t *testing.T) {
+ r := exchangeRequest(p.credential.App, "GET", Origin+"/authorize/resume", "", nil, intent, session)
+ m := regexp.MustCompile(`name="assertion" value="([^"]+)"`).FindStringSubmatch(r.Body.String())
+ if r.Code != 200 || len(m) != 2 {
+ t.Fatal("no straight-in mint", r.Code)
+ }
+ callback := exchangeRequest(p.directory, "POST", directoryOrigin+handoff.CallbackPath, Origin, url.Values{"assertion": {html.UnescapeString(m[1])}})
+ if sessionCookie(callback) != nil {
+ t.Fatal("the callback minted a session")
+ }
+ cookies := []*http.Cookie{pending}
+ for _, c := range callback.Result().Cookies() {
+ if c.Name == "__Host-oficina-assertion-inbox" && c.Value != "" {
+ cookies = append(cookies, c)
+ }
+ }
+ finish := exchangeRequest(p.directory, "GET", directoryOrigin+handoff.FinishPath, "", nil, cookies...)
+ if sessionCookie(finish) != nil || finish.Header().Get("Location") == "/?team=blue" {
+ t.Fatal("a foreign nonce signed this browser in", finish.Code)
+ }
+ })
+ }
+}
+
+// TestIDStraightInMintsOnlyForANavigation: the minting GET refuses a
+// prefetch or prerender, and anything a browser says is not a top-level
+// document navigation; a browser that sends no Sec-Fetch headers is
+// judged on the purpose headers alone.
+func TestIDStraightInMintsOnlyForANavigation(t *testing.T) {
+ p := newExchangePair(t)
+ session := signInFully(t, p.credential, sealtest.CanaryAddress)
+ _, intent := p.start(t)
+ navigate := map[string]string{"Sec-Fetch-Mode": "navigate", "Sec-Fetch-Dest": "document", "Sec-Fetch-Site": "cross-site"}
+ with := func(base map[string]string, k, v string) map[string]string {
+ out := map[string]string{}
+ for a, b := range base {
+ out[a] = b
+ }
+ if v == "" {
+ delete(out, k)
+ } else {
+ out[k] = v
+ }
+ return out
+ }
+ get := func(headers map[string]string) *httptest.ResponseRecorder {
+ r := httptest.NewRequest("GET", Origin+"/authorize/resume", nil)
+ r.AddCookie(intent)
+ r.AddCookie(session)
+ for k, v := range headers {
+ r.Header.Set(k, v)
+ }
+ w := httptest.NewRecorder()
+ p.credential.Router().ServeHTTP(w, r)
+ return w
+ }
+ for name, headers := range map[string]map[string]string{
+ "prefetch": with(navigate, "Sec-Purpose", "prefetch"),
+ "prerender": with(navigate, "Sec-Purpose", "prefetch;prerender"),
+ "legacy prefetch": {"Purpose": "prefetch"},
+ "fetch()": with(with(navigate, "Sec-Fetch-Mode", "cors"), "Sec-Fetch-Dest", "empty"),
+ "no-cors": with(with(navigate, "Sec-Fetch-Mode", "no-cors"), "Sec-Fetch-Dest", "image"),
+ "iframe": with(navigate, "Sec-Fetch-Dest", "iframe"),
+ "mode without dest": with(navigate, "Sec-Fetch-Dest", ""),
+ "dest without mode": with(navigate, "Sec-Fetch-Mode", ""),
+ } {
+ if r := get(headers); r.Code == 200 || strings.Contains(r.Body.String(), `name="assertion"`) {
+ t.Errorf("%s minted: %d", name, r.Code)
+ }
+ }
+ for name, headers := range map[string]map[string]string{"navigation": navigate, "no Sec-Fetch headers": {}} {
+ if r := get(headers); r.Code != 200 || !strings.Contains(r.Body.String(), `name="assertion"`) {
+ t.Errorf("%s did not mint: %d", name, r.Code)
+ }
+ }
+}
+
// TestIDStraightInWithoutSessionIsTheDoor: no id.* session, no mint; the
// sign-in door, coming back to the resume.
func TestIDStraightInWithoutSessionIsTheDoor(t *testing.T) {