Open source Loom alternative. Beautiful, shareable screen recordings.
Rust appcapcossloommacnextjsnextjs15open-sourceossreactrecordrustscreen-capturescreen-recorderscreenshotsolidjstauritauri-apptypescriptvite
fix: treat filesystem lookup failures as not a public asset
Shae Feltzc17e012b4403
diff --git a/apps/web/__tests__/unit/proxy-self-hosted.test.ts b/apps/web/__tests__/unit/proxy-self-hosted.test.tsindex 7026bea46..40b5cdf38 100644--- a/apps/web/__tests__/unit/proxy-self-hosted.test.ts+++ b/apps/web/__tests__/unit/proxy-self-hosted.test.ts@@ -71,6 +71,11 @@ describe("self-hosted proxy routes", () => {it("rejects path traversal out of public/", () =>expectLoginRedirect("/logos/..%2F..%2Fproxy.ts"));+ it.each(["/%00", "/favicon.ico/nested.svg", `/${"a".repeat(5000)}.svg`])(+ "treats a filesystem lookup failure for %s as not an asset",+ (path) => expectLoginRedirect(path),+ );+it("does not treat a share link as an asset", () =>expectServed("/s/video123"));});diff --git a/apps/web/proxy.ts b/apps/web/proxy.tsindex be53d84c3..02eadcecf 100644--- a/apps/web/proxy.ts+++ b/apps/web/proxy.ts@@ -16,15 +16,13 @@ const addHttps = (s?: string) => {const publicDir = resolve(process.cwd(), "public");const isPublicAsset = (path: string) => {- let decoded: string;try {- decoded = decodeURIComponent(path);+ const file = resolve(publicDir, `.${decodeURIComponent(path)}`);+ if (!file.startsWith(`${publicDir}${sep}`)) return false;+ return statSync(file, { throwIfNoEntry: false })?.isFile() ?? false;} catch {return false;}- const file = resolve(publicDir, `.${decoded}`);- if (!file.startsWith(`${publicDir}${sep}`)) return false;- return statSync(file, { throwIfNoEntry: false })?.isFile() ?? false;};const mainOrigins = [