From 374afce1c93e25373eadce258edaa0398fb99faf Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Wed, 2 Dec 2026 10:34:36 -0700 Subject: migrate: grant the registrar the session's own name, not the form's The /migrate action told the names registrar which v3 identity may claim a name, using the `username` field from the submitted form. Any logged-in account could post another user's name and be granted it. Look the name up from the session (/me) instead, and refuse before sweeping or flagging anything when there is no session. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01VMan6SSfVopM1ZzXKZmLYU --- src/routes/(app)/migrate/+page.server.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'src/routes/(app)/migrate/+page.server.ts') diff --git a/src/routes/(app)/migrate/+page.server.ts b/src/routes/(app)/migrate/+page.server.ts index 6559485f..494eb5b8 100644 --- a/src/routes/(app)/migrate/+page.server.ts +++ b/src/routes/(app)/migrate/+page.server.ts @@ -1,4 +1,4 @@ -import { auth, post } from "$lib/utils"; +import { auth, get, post } from "$lib/utils"; import { redirect } from "@sveltejs/kit"; import { env } from "$env/dynamic/private"; @@ -60,8 +60,13 @@ export const actions = { const to = String(form.get("to") || url.searchParams.get("to") || ""); const pin = String(form.get("pin") || ""); const balance = Number(form.get("balance") || 0); - const username = String(form.get("username") || ""); if (!to) return { error: "no destination" }; + // The name handed to the registrar has to be the one this session is + // logged in as. Never take it from the form, or any account could have + // the registrar grant it someone else's @coinos.io name. + const me = await get("/me", auth(cookies)).catch(() => null); + const username = me?.username; + if (!username) return { error: "not logged in" }; let sent = 0; try { -- cgit v1.2.3