oficina / home Public

Make receipt-tampering regression deterministic

Co-Authored-By: Codex <noreply@openai.com>
Codex (OpenAI) pushed by paul@keymail.dev 0c8affb67924909c710d724609560d93e6ec47f3 parent c37280e
2 files changed, +16 −1
  • implementation/oficina-id-slice1-validation.md +7 −0
  • internal/home/team_add_test.go +9 −1

CI passed — run details

diff --git a/implementation/oficina-id-slice1-validation.md b/implementation/oficina-id-slice1-validation.md
index 61d18b7..a08acca 100644
--- a/implementation/oficina-id-slice1-validation.md
+++ b/implementation/oficina-id-slice1-validation.md
@@ -156,3 +156,10 @@ GPT-6 Astra performed the delegated copy and independent source reviews.
The agent's coordination and review record is Amadan discussion 107; the prompt
ledger is retained on the branch. The final source/tests/records approval before
this authorship note was af703f4735776f6fc1a915369348d40b1548f8f9.
+
+Final hosted CI exposed an unrelated probabilistic fixture in
+TestResolvedRefusals: replacing the receipt's last two characters with AA can
+leave the original signature unchanged. The test now flips a decoded signature
+byte and re-encodes it, guaranteeing different bytes. Production verification
+is unchanged. The corrected test passed 20 consecutive runs. The full browser
+gate already passed; the full local gate continues through its race suites.
diff --git a/internal/home/team_add_test.go b/internal/home/team_add_test.go
index 51d5a14..7e24835 100644
--- a/internal/home/team_add_test.go
+++ b/internal/home/team_add_test.go
@@ -199,6 +199,14 @@ func TestResolvedRefusals(t *testing.T) {
f.member(t, f.sqid, secondOwner, "owner")
foreign := &http.Cookie{Name: teamIntentCookie, Value: fixtureToken(77)}
+ payload, encodedSignature, _ := strings.Cut(a.receipt, ".")
+ signature, err := base64.RawURLEncoding.DecodeString(encodedSignature)
+ if err != nil || len(signature) == 0 {
+ t.Fatal("invalid fixture signature")
+ }
+ signature[len(signature)-1] ^= 1
+ tampered := payload + "." + base64.RawURLEncoding.EncodeToString(signature)
+
refused := map[string]*httptest.ResponseRecorder{
"wrong Origin": exchangeRequest(f.directory, "POST", directoryOrigin+teamResolvedPath, directoryOrigin, url.Values{"receipt": {a.receipt}}, dir, a.intent),
"no Origin": exchangeRequest(f.directory, "POST", directoryOrigin+teamResolvedPath, "", url.Values{"receipt": {a.receipt}}, dir, a.intent),
@@ -212,7 +220,7 @@ func TestResolvedRefusals(t *testing.T) {
"no session": f.resolved(a.receipt, a.intent),
"no intent cookie": f.resolved(a.receipt, dir),
"another add's id": f.resolved(a.receipt, dir, foreign),
- "tampered": f.resolved(a.receipt[:len(a.receipt)-2]+"AA", dir, a.intent),
+ "tampered": f.resolved(tampered, dir, a.intent),
"oversized": f.resolved(strings.Repeat("A", memberReceiptLimit+1), dir, a.intent),
"two fields": exchangeRequest(f.directory, "POST", directoryOrigin+teamResolvedPath, Origin, url.Values{"receipt": {a.receipt}, "team": {"zzzz"}}, dir, a.intent),
}