Reject null-byte encoded static asset paths

Co-authored-by: Theo Browne <[email protected]>
This commit is contained in:
Cursor AgentandTheo Browne committed 2026-02-10 00:50:26 +00:00
1 parent 06785908e1
commit a9bb1d6b19
2 files changed
+10

No files matched your search

+7
View File
@@ -364,6 +364,13 @@ describe("resolveStaticAssetPath", () => {
kind: "bad_request",
});
});
it("rejects null-byte encoded paths", () => {
const result = resolveStaticAssetPath("/index.html%00", distRoot);
expect(result).toEqual({
kind: "bad_request",
});
});
});
describe("resolveStaticAssetReadTarget", () => {
+3
View File
@@ -377,6 +377,9 @@ export function resolveStaticAssetPath(
} catch {
return { kind: "bad_request" };
}
if (decodedPath.includes("\0")) {
return { kind: "bad_request" };
}
const normalizedPath =
decodedPath === "/" ? "index.html" : decodedPath.replace(/^\/+/, "");