Repository navigation
Fix saved-route id collisions, lock down OSM cache writes, close login open redirect, add web CI - #17
Merged
SpencerLiang0114 merged 4 commits intoOct 5, 2026
Conversation
Saves upserted on the client route id, but generated (generated-loop-N), uploaded (uploaded-<slug>) and Strava ids repeat across generations and users: a new save silently overwrote an earlier one with the same id, and any other user got a permanent 403. POST /api/saved-routes now inserts a new saved-<uuid> row. On the frontend, the saved copy replaces its candidate in the persisted results, so the view stays "Saved" and shares the real saved id after switching routes or reloading, instead of matching the library by client id. Save is guarded while in flight, deleting a route turns a reopened copy back into a savable candidate, and logout clears the library state. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Route generation trusts cached Overpass elements, and PUT /api/osm-graph-cache let anyone replace them for any bbox for up to 24h. The PUT now lives in a controller that is only registered when ROUTECRAFT_OSM_CACHE_WRITE_ENABLED=true, which only the offline smoke test compose override sets. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Browsers treat "\" as "/" and drop tabs, so /login?next=/%5Cevil.com passed the old prefix checks and sent signed-in users off-site. Login, register and the auth gate now share one check that also rejects backslashes, control characters and anything resolving to another origin. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Add a Web workflow running lint, tsc, vitest and next build for apps/web. Check Postgres health over TCP: the image's init-time server listens only on the socket, so socket checks passed just before it shut down and the integration job's createdb could hit "the database system is shutting down". Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
@victory-c is attempting to deploy a commit to the spencerliang0114's projects Team on Vercel. A member of the Team first needs to authorize it. |
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.
Four independent fixes, one commit each.
1. Saved routes overwrite each other (
6289909)Problem.
POST /api/saved-routesupserted on the route id the client sent. Those ids repeat:generated-loop-1,generated-loop-2, … in every run, from both the Rust and Java engines.uploaded-<slug>.strava-segment-<id>.The global
saved_routes.idprimary key turned that into two bugs:403 You do not own this saved routefor theirs.Fix (backend).
SavedRouteRepository.createalways inserts a new row with a server-assigned id,saved-<uuid>. The ownership lookup andON CONFLICTare gone. Existing rows, PATCH, DELETE and shares are unchanged and still scoped byuser_id.Fix (frontend).
results, andactiveRouteIdfollows it. After switching routes or reloading, the view still shows "Saved" and Share uses the real saved id.ExportButtonsno longer matches the library by client id. That match would hand a new loop refactor: backend owns route generation, restructure to apps/web layout #1 last week's share.2. Anyone could rewrite the OSM street graph (
b76877f)Problem.
PUT /api/osm-graph-cachewas anonymous and exempt from CSRF. It replaced existing rows and accepted anyelementswith a TTL of up to 24h, and route generation reads that cache before Overpass. Anyone could swap the street graph for a popular start point.Fix. The PUT moved to
OsmGraphCacheSeedController. That controller is only registered whenROUTECRAFT_OSM_CACHE_WRITE_ENABLED=true, which onlyservices/routing-compat/compose.test.ymlsets, forseed-smoke.py. Otherwise the endpoint returns405and never parses the body. GET is unchanged.3. Open redirect after login (
9acd53c)Problem.
sanitizeNextlet these through:/\evil.comand/<tab>/evil.com: browsers read\as/and drop tabs././/evil.comand/x/%2e%2e//evil.com: dot segments normalize to the path//evil.com, which the Next router then navigates to.So
/login?next=/%5Cevil.comsent signed-in users off-site.Fix. Login, Register and AuthGate now share
lib/safeNextPath.ts. It rejects backslashes and control characters, resolves the value against a fixed origin, and checks and returns the normalized path.4. CI (
642dd5e)Webworkflow runningpnpm lint,tsc --noEmit,vitestandnext buildforapps/web. None of these ran in CI before.createdbcould then fail with "the database system is shutting down" (seen onmainin run 35743597468).Tests
./mvnw clean test: 49 tests, 0 failures, 1 skipped (the opt-in integration test).SavedRouteRepositoryTests: the server assigns the id, and repeat saves get distinct ids.OsmGraphCacheSeedTests: PUT returns405when disabled and works when enabled.pnpm lint,tsc --noEmitandpnpm buildare clean.pnpm testruns 25 tests.safeNextPathtests cover every bypass above.routeStoretests cover save swap, delete,clearLibrary, and repeated client ids.Note
This is based on
main. Until #16 (the CSRF fix) lands, every saved-route write from the browser still gets a CSRF 403, so test the saving flow end to end with both merged.🤖 Generated with Claude Code