Skip to content

Open-source platform for 3D AI agents. Turn text or a photo into a rigged, animated GLB avatar, give it an LLM brain, memory and a wallet, and embed it anywhere with one web component. Remote MCP server, x402 payments, Three.js, browser-native.

fix(seeker): require the CSRF token on Seeker verification like every other session-mutating route

nirholas7428fe97c96d
diff --git a/api/seeker/[action].js b/api/seeker/[action].js
index e5dc451f4..e9797f61e 100644
--- a/api/seeker/[action].js
+++ b/api/seeker/[action].js
@@ -9,6 +9,7 @@
import { z } from 'zod';
import { sql } from '../_lib/db.js';
import { getSessionUser } from '../_lib/auth.js';
+import { requireCsrf } from '../_lib/csrf.js';
import { cors, json, method, readJson, wrap, error, rateLimited } from '../_lib/http.js';
import { limits, clientIp } from '../_lib/rate-limit.js';
import { parse } from '../_lib/validate.js';
@@ -69,6 +70,9 @@ async function handleVerify(req, res) {
if (!method(req, res, ['POST'])) return;
const user = await getSessionUser(req, res);
if (!user?.id) return error(res, 401, 'unauthorized', 'sign in to verify a Seeker');
+ // Same rule as every other session-mutating route: a cross-site form post
+ // must not be able to trigger a re-scan on the victim's behalf.
+ if (!(await requireCsrf(req, res, user.id))) return;
const rl = await limits.authIp(clientIp(req));
if (!rl.success) return rateLimited(res, rl, 'too many verification attempts');
diff --git a/src/seeker.js b/src/seeker.js
index 0968095ab..c566ec0f6 100644
--- a/src/seeker.js
+++ b/src/seeker.js
@@ -8,6 +8,7 @@
import { isSolanaMobileTwa, isSolanaMobileDevice } from '../solana-mobile/src/seeker-detect.js';
import { isUserRejection } from '../solana-mobile/src/mwa-errors.js';
+import { apiFetch } from './api.js';
// The wallet stack (Mobile Wallet Adapter + @solana/web3.js) is ~700 KB. It
// is only needed to sign in, so the home screen loads without it: inside the
@@ -53,8 +54,10 @@ function escapeHtml(s) {
return String(s).replace(/[&<>"']/g, (c) => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#39;' })[c]);
}
+// apiFetch carries the session cookie and, on mutations, the x-csrf-token the
+// server requires; a plain fetch would be refused by /api/seeker/verify.
async function fetchJson(url, init = {}) {
- const res = await fetch(url, { credentials: 'include', ...init });
+ const res = await apiFetch(url, { credentials: 'include', ...init });
const body = await res.json().catch(() => null);
return { ok: res.ok, status: res.status, body };
}