Repository navigation
fix(bets): GET /api/bets was readable with no session (v0.453.1) - #852
Merged
Merged
Conversation
The route landed beside the agent loopback routes, which sit above the /api/* auth gate, so every bet on the tenant — titles, hypotheses, baselines, asset URLs — was served to anyone who could reach the port. The handler was fine; its POSITION was the bug, so the test is about reachability without a cookie rather than about the handler. Also adds the human write side the board needs (PATCH /api/bets/:id and POST /api/bets/:id/judge, owner/admin): decide + record the lesson, or force the arithmetic early. The measured columns stay unwritable — not even an owner can type a number over a measurement. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The bug
GET /api/betsshipped in v0.453.0 above the/api/*auth gate — it was added beside the agent loopback routes (/api/agent/bets/*), which are deliberately pre-auth because they carry their own session-secret check. So the board route inherited no gate at all:Every bet on the tenant — titles, hypotheses, baselines, asset URLs — to anyone who could reach the port. On the Mac Mini that is the tailnet rather than the internet, which is why this is a 🔴 rather than a 🚨, but it is the same class of mistake as a missing
auth_request.The handler was correct. Its position in the file was the bug.
Fix
scripts/bets-test.cjsnow asserts an un-cookiedGET /api/betsand an un-cookiedPATCH /api/bets/:idboth return 401. A position bug needs a reachability test; a handler test would have passed throughout.Also
The human write side the board needs, owner/admin gated:
PATCH /api/bets/:id— state + lesson (and hypothesis/baseline/expected/window). A terminal state requires a lesson, exactly as the agent lane does.POST /api/bets/:id/judge— run the arithmetic early on a window a human has already seen enough of; audited withearly: true.The measured columns stay unwritable from both lanes: the test pins that an owner PATCHing
observedLift: 99changes nothing.🤖 Generated with Claude Code