Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion packages/core/src/studio-api/routes/render.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { Hono } from "hono";
import { streamSSE } from "hono/streaming";
import { existsSync, readFileSync, mkdirSync, unlinkSync, readdirSync, statSync } from "node:fs";
import { join } from "node:path";
import { join, resolve } from "node:path";
import type { StudioApiAdapter, RenderJobState } from "../types.js";

export function registerRenderRoutes(api: Hono, adapter: StudioApiAdapter): void {
Expand Down Expand Up @@ -182,8 +182,10 @@ export function registerRenderRoutes(api: Hono, adapter: StudioApiAdapter): void
if (!project) return c.json({ error: "not found" }, 404);
const filename = c.req.path.split("/renders/file/")[1];
if (!filename) return c.json({ error: "missing filename" }, 400);
if (filename.includes("..")) return c.json({ error: "forbidden" }, 403);
const rendersDir = adapter.rendersDir(project);
const fp = join(rendersDir, filename);
if (!fp.startsWith(resolve(rendersDir))) return c.json({ error: "forbidden" }, 403);
if (!existsSync(fp)) return c.json({ error: "not found" }, 404);
const contentType = renderContentType(fp);
const content = readFileSync(fp);
Expand Down
Loading