mirror of
https://github.com/Moepchi/webspeak3.git
synced 2026-12-03 01:42:50 +08:00
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 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Hu2cuPLqpuKVfd9wWFFakU
This commit is contained in:
1 parent
667012d710
commit
83afe6c2cd
1 file changed
+1
-1
@@ -383,7 +383,7 @@ const requestHandler = (req: IncomingMessage, res: ServerResponse) => {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
let filePath = path.join(WEB_DIST, decodeURIComponent(requestUrl.pathname));
|
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.writeHead(403);
|
||||||
res.end();
|
res.end();
|
||||||
return;
|
return;
|
||||||
|
|||||||
Reference in new issue
Block a user