commit b81c263a070962571e5229e688fc125f4991d446
parent e49ba3f58a78906a396fdf8d3a6ce553e108a7da
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date: Tue, 10 Nov 2026 10:53:52 -0500
umtool: home's Quick clip render and the timeline's writes refuse another site's POST too; the quick-clip route says which ids it takes (L4 security re-review)
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Diffstat:
3 files changed, 12 insertions(+), 1 deletion(-)
diff --git a/umtool/app/api/report/quick-clip/route.ts b/umtool/app/api/report/quick-clip/route.ts
@@ -1,6 +1,7 @@
import path from "node:path";
import { getJob, jobView, runningJob, startJob } from "@/lib/jobs";
import { refuseCaller } from "@/lib/report/caller";
+import { crossSiteRefusal } from "@/lib/report/sameOrigin.mjs";
import { UMTOOL_DIR } from "@/lib/report/driver.mjs";
import { quickClipSpec } from "@/lib/report/quickClip.mjs";
@@ -23,11 +24,14 @@ const SITE_RE = /^[a-z0-9][a-z0-9._-]*$/i;
export async function POST(request: Request) {
const refused = refuseCaller(request, "/api/report/quick-clip");
if (refused) return refused;
+ // Another site's page may not write here (lib/report/sameOrigin.mjs: Sec-Fetch-Site, Origin, a loopback Host).
+ const cross = crossSiteRefusal(request.headers);
+ if (cross) return Response.json({ error: cross }, { status: 403 });
const body = (await request.json().catch(() => null)) as Record<string, unknown> | null;
if (!body || typeof body !== "object") return Response.json({ error: "expected JSON" }, { status: 400, headers });
const spec = String(body.spec ?? "").trim();
if (!quickClipSpec(spec)) {
- return Response.json({ error: 'spec is <channel>/<video>@<start>-<end> in seconds, the end after the start, its ids neither "." nor starting "-"' }, { status: 400, headers });
+ return Response.json({ error: 'spec is <channel>/<video>@<start>-<end> in seconds, the end after the start, its ids not dots, the channel not starting "-", the video only when a YouTube id (11 characters)' }, { status: 400, headers });
}
const snap = body.snap === undefined || body.snap === null || body.snap === "" ? null : String(body.snap);
if (snap !== null && snap !== "words") return Response.json({ error: "snap is words, or nothing" }, { status: 400, headers });
diff --git a/umtool/app/api/report/timeline/route.ts b/umtool/app/api/report/timeline/route.ts
@@ -1,5 +1,6 @@
import { invalidateProjects } from "@/lib/projects";
import { withEditNotes } from "@/lib/report/guard";
+import { crossSiteRefusal } from "@/lib/report/sameOrigin.mjs";
import {
StaleToken,
StructureRefused,
@@ -130,6 +131,9 @@ const atOf = (v: unknown) => (v === undefined || v === null || v === "" ? null :
export async function POST(request: Request) {
const refused = refuseCaller(request, "/api/report/timeline");
if (refused) return refused;
+ // Another site's page may not write here (lib/report/sameOrigin.mjs: Sec-Fetch-Site, Origin, a loopback Host).
+ const cross = crossSiteRefusal(request.headers);
+ if (cross) return Response.json({ error: cross }, { status: 403 });
let body: Body;
try {
body = await request.json();
diff --git a/umtool/lib/inbox/needs-you.test.ts b/umtool/lib/inbox/needs-you.test.ts
@@ -254,6 +254,9 @@ test("the one-press routes refuse another site's write (sameOrigin.mjs) and stil
{ mod: await import("../../app/api/report/links/route"), method: "POST" as const, body: { project: "ny-cut", fix: true } },
{ mod: await import("../../app/api/report/takes/verdict/route"), method: "POST" as const, body: { project: "ny-cut", take: "v2", verdict: "like" } },
{ mod: await import("../../app/api/report/window/route"), method: "PUT" as const, body: { project: "ny-cut", clip: "c02", lockCut: true } },
+ // Home's Quick clip render (it starts a job) and the timeline's writes (Add clip).
+ { mod: await import("../../app/api/report/quick-clip/route"), method: "POST" as const, body: { spec: "nychan/nyfresh@1-2" } },
+ { mod: await import("../../app/api/report/timeline/route"), method: "POST" as const, body: { project: "ny-cut", op: "remove", id: "c03" } },
];
for (const { mod, method, body } of routes) {
const handler = (mod as unknown as Record<string, (r: Request) => Promise<Response>>)[method];