Skip to content

Hackathon-audit fixes: security, gameplay, durable anti-replay, docs & tests - #44

Merged
analiaacostaok merged 5 commits into
mainfrom
chore/audit-fixes
Jun 24, 2026
Merged

analiaacostaok merged 5 commits into
mainfrom
chore/audit-fixes

Conversation

@analiaacostaok

Copy link
Copy Markdown
Member

Audit pass over the codebase (as a hackathon judge would): security & gameplay fixes, a durable replay guard, broader test coverage, and a full documentation sync. All green: `format:check`, `lint`, `typecheck`, 185 unit tests, and 7 integration tests (against the Neon test branch).

Commits (logical, reviewable)

  • chore: format the repo with Prettier + add `.prettierignore` (build output + generated migration metadata). Formatting drift had been landing because nothing enforced it.
  • fix(game): resolve food strictly by the nearest lane — a mid-tween merge toward a booster could clip the junk in the lane being left; booster gauntlets are now dodgeable as designed. Also reads the per-match track length from the active track.
  • feat(multiplayer): host-only race start — the `control` (start) event now carries its signer and the reducer only advances when it matches the match host, so a rogue peer on the channel can't force-start the race. Also derives the lobby host from the host's own presence.
  • feat(auth): durable NIP-98 anti-replay — single-use login nonces move from in-process memory to a Postgres `auth_nonces` table (idempotent insert + `ON CONFLICT DO NOTHING` + expired-row sweep), so a captured `Authorization` header can't be replayed by landing on a different serverless instance. Adds the migration, a unit test (mocked DB), and an integration test (real Neon test branch); `test:integration` now auto-loads `.env.test` so it runs locally.
  • docs: sync documentation and UI copy with the implementation — session TTL, auth methods (NIP-07/46/nsec), scoring table, junk-food copy (bounded bathroom setback), security/anti-replay/host-start behavior, PWA, the live demo link, food variety, the account menu and the lud16/sync-profile routes, refreshed project structure, and removed stale "in progress / future work" notes.

Migration

Adds `auth_nonces` (migration `0004`). Production applies it automatically via the `migrate.yml` workflow on merge; the Neon test branch has already been migrated.

Notes for the reviewer

  • Replay guard is concurrency-safe: `ON CONFLICT DO NOTHING` is atomic, and the pre-insert sweep can't delete a freshly inserted (future-dated) row.
  • Host check is best-effort while the host is still unknown (no authoritative server) — `state.host` is seeded from the trusted invite link, so it isn't poisonable by a malicious presence.
  • Rate limiting was deliberately left in-process (best-effort): making it durable would add a DB write per API request without closing a real hole.

🤖 Generated with Claude Code

analiaacostaok and others added 5 commits June 24, 2026 18:58
Brings the whole tree to Prettier code style and ignores build output and
generated migration metadata so formatting drift can't land again.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Food now resolves against the runner's rounded lane only, so a mid-tween
merge toward a booster can't clip the junk in the lane being left — keeping
booster gauntlets dodgeable as designed. Also reads the per-match track
length from the active track instead of the shared default, removing a
latent mismatch if a future seed changes length.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The control (start) event now carries its signer (the host's real identity)
and the reducer only advances the lifecycle when that signer matches the
match host — so a rogue peer on the channel can't force-start the race for
everyone. Best-effort while the host is still unknown (no authoritative
server). Also derives the lobby card's host from the host's own presence
rather than whichever seat arrived first.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Single-use login nonces move from in-process memory to an auth_nonces table
(idempotent insert + ON CONFLICT DO NOTHING + expired-row sweep), so a
captured Authorization header can't be replayed by landing on a different
Vercel serverless instance. Adds the migration, a unit test (mocked DB) and
an integration test against the real Neon test branch; test:integration now
auto-loads .env.test so it runs locally.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Corrects session TTL, auth methods (NIP-07/46/nsec), scoring table, junk-food
copy (bounded bathroom setback), and the security/anti-replay/host-start
behavior; adds PWA, the live demo link, food variety, the account menu and the
lud16/sync-profile routes; refreshes the project structure and removes stale
'in progress / future work' notes.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@vercel

vercel Bot commented Jun 24, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
bitbybit-run Ready Ready Preview, Comment Jun 24, 2026 10:01pm

@analiaacostaok
analiaacostaok merged commit b9ce9a9 into main Jun 24, 2026
5 checks passed
@analiaacostaok
analiaacostaok deleted the chore/audit-fixes branch June 24, 2026 22:09

This branch was successfully deployed

1 active deployment
Preview — f54243a1 Deployed Jun 24, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant