From 83afe6c2cd8735a23b85a4760373df3ce5f43ca6 Mon Sep 17 00:00:00 2001 From: Moepchi Date: Thu, 17 Sep 2026 17:35:54 +0000 Subject: [PATCH] Fix path-traversal-adjacent bypass in static file containment check The WEB_STATIC file server checked containment with a plain string prefix (filePath.startsWith(WEB_DIST)), which a sibling directory sharing that prefix passes without actually being inside WEB_DIST - e.g. WEB_DIST "/app/web/dist" also accepts "/app/web/dist-backup/...". Now requires an exact match or a path-separator boundary. WEB_STATIC defaults to on, so this affects any self-hoster serving the UI from the gateway with the stock config, not just this deployment. Co-Authored-By: Claude Sonnet 5 Claude-Session: https://claude.ai/code/session_01Hu2cuPLqpuKVfd9wWFFakU --- gateway/src/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gateway/src/index.ts b/gateway/src/index.ts index 624a36d..38f8043 100644 --- a/gateway/src/index.ts +++ b/gateway/src/index.ts @@ -383,7 +383,7 @@ const requestHandler = (req: IncomingMessage, res: ServerResponse) => { return; } let filePath = path.join(WEB_DIST, decodeURIComponent(requestUrl.pathname)); - if (!filePath.startsWith(WEB_DIST)) { + if (filePath !== WEB_DIST && !filePath.startsWith(WEB_DIST + path.sep)) { res.writeHead(403); res.end(); return;