oficina / home Public

Prevent storage of credential pages and recovery-code responses

Paul Campbell pushed by paul@keymail.dev c2eeb346aec1064202176ac5b87d4b7fc93b49da parent b8cf490
5 files changed, +41 −1
  • implementation/oficina-id-slice1-mutations.json +10 −0
  • implementation/oficina-id-slice1-validation.md +9 −1
  • internal/home/id_recovery_test.go +16 −0
  • internal/home/render.go +3 −0
  • scripts/check-id-mutations.py +3 −0

CI passed — run details

diff --git a/implementation/oficina-id-slice1-mutations.json b/implementation/oficina-id-slice1-mutations.json
index 254cd92..8818082 100644
--- a/implementation/oficina-id-slice1-mutations.json
+++ b/implementation/oficina-id-slice1-mutations.json
@@ -640,5 +640,15 @@
"--- FAIL: TestIDFreshIntentRequiresStartTime (0.29s)"
],
"seconds": 2.12
+ },
+ {
+ "guard": "credential page cache privacy",
+ "file": "internal/home/render.go",
+ "test": "TestIDCredentialPagesAreNoStore",
+ "result": "killed",
+ "failures": [
+ "--- FAIL: TestIDCredentialPagesAreNoStore (0.15s)"
+ ],
+ "seconds": 1.83
}
]
diff --git a/implementation/oficina-id-slice1-validation.md b/implementation/oficina-id-slice1-validation.md
index c6ac1de..a3cab05 100644
--- a/implementation/oficina-id-slice1-validation.md
+++ b/implementation/oficina-id-slice1-validation.md
@@ -60,7 +60,7 @@ Pending.
## Mutation result
-`scripts/check-id-mutations.py` ran 62 guard-removal checks. 61 were killed by
+`scripts/check-id-mutations.py` ran 63 guard-removal checks. 62 were killed by
behavioral regressions. Removing only the SQL recovery-subject predicate
survived because the independent mailbox subject check still refused the proof;
removing both checks was killed. The JSON record names every guard, test and
@@ -100,3 +100,11 @@ exact final SHA are recorded in branch discussion 107 and the requested report.
GPT-6 Astra approved source/tests; deployed-canary review remains outstanding
under Paul's no-deploy instruction. No merge was attempted. Equipo and shared
consumer adapter changes remain part B.
+
+A final renderer check found credential HTML lacked explicit no-store headers.
+`TestIDCredentialPagesAreNoStore` failed before the fix. The shared renderer now
+sets no-store on credential-origin HTML, including shown-once recovery codes;
+static assets retain their own cache policy. The regression passes and removing
+the header is killed by mutation. The final record is 63 checks / 62 killed /
+one independently guarded survivor. Targeted renderer and browser tests follow
+this final three-line production change; final-tip CI reruns the full gate.
diff --git a/internal/home/id_recovery_test.go b/internal/home/id_recovery_test.go
index 37a10ea..a194cc8 100644
--- a/internal/home/id_recovery_test.go
+++ b/internal/home/id_recovery_test.go
@@ -461,3 +461,19 @@ func TestIDCodesRequireEnrolledPasskey(t *testing.T) {
t.Fatal("codes issued before passkey enrollment")
}
}
+
+func TestIDCredentialPagesAreNoStore(t *testing.T) {
+ a := newTestApp(t)
+ s := signInFully(t, a, sealtest.CanaryAddress)
+ enrol(t, a, s)
+ for _, path := range []string{"/signin", "/passkey/enrol", "/passkey/codes", "/passkey/replace", "/passkey/replaced"} {
+ r := exchangeRequest(a.App, "GET", Origin+path, "", nil, s)
+ if r.Header().Get("Cache-Control") != "no-store" {
+ t.Fatal("credential page permits storage", path)
+ }
+ }
+ r := exchangeRequest(a.App, "POST", Origin+"/passkey/codes", Origin, url.Values{}, s)
+ if r.Code != 200 || r.Header().Get("Cache-Control") != "no-store" {
+ t.Fatal("shown-once codes permit storage")
+ }
+}
diff --git a/internal/home/render.go b/internal/home/render.go
index 2ac21ab..072d526 100644
--- a/internal/home/render.go
+++ b/internal/home/render.go
@@ -101,6 +101,9 @@ func (a *App) render(w http.ResponseWriter, r *http.Request, status int, page st
// the opposite of what happened. A page that fails is answered with the
// 500 page; if that one fails too, with plain text.
func (a *App) renderPage(w http.ResponseWriter, r *http.Request, status int, name string, data any) {
+ if a.onCredential(r) {
+ w.Header().Set("Cache-Control", "no-store")
+ }
t, ok := a.renderer.pages[name]
if !ok {
a.logger.Error("no such page template", "page", name)
diff --git a/scripts/check-id-mutations.py b/scripts/check-id-mutations.py
index 31e9144..76a7138 100755
--- a/scripts/check-id-mutations.py
+++ b/scripts/check-id-mutations.py
@@ -71,6 +71,9 @@ CASES += [
("codes after enrollment","passkey.go", 'if enrolled == 0 {', 'if enrolled == 0 && false {', "TestIDCodesRequireEnrolledPasskey"),
("fresh intent start provenance","assertion_intent.go", 'intent.Started <= 0 || intent.Started > now.Unix()', '(intent.Started <= 0 && false) || intent.Started > now.Unix()', "TestIDFreshIntentRequiresStartTime"),
]
+CASES += [
+ ("credential page cache privacy","render.go", 'w.Header().Set("Cache-Control", "no-store")', 'w.Header().Set("Cache-Control", "")', "TestIDCredentialPagesAreNoStore"),
+]
for table in ("sessions", "passkey_credentials", "passkey_recovery_codes", "passkey_pending", "passkey_challenges", "home_id_ceremonies", "home_id_recovery_proofs"):
CASES.append(("replacement revokes " + table,"id_recovery.go",f'\n\t\t"DELETE FROM {table} WHERE subject=?",',f'\n\t\t"DELETE FROM {table} WHERE subject=? AND 0",',"TestIDRecoveryReplacementRevokesEverything"))