fix(docker-server): reject null bytes in resolvePath

Defensively harden the path traversal guard by returning null
early when the URL contains a null byte, before normalization runs.

Made-with: Cursor
This commit is contained in:
kritik.b 2026-04-16 08:35:21 +05:30
parent 3504945367
commit 856d9a4b97

View file

@ -21,6 +21,7 @@ const contentTypes = {
};
function resolvePath(urlPath) {
if (urlPath.includes('\0')) return null;
const cleanPath = normalize(decodeURIComponent(urlPath).replace(/^\/+/, ''));
const candidate = join(root, cleanPath);
if (!candidate.startsWith(root)) return null;