Skip to content

Commit efe8dc6

Browse files
committed
fix(sdk): also reject Windows-separator nav paths in the docs bundler
POSIX normalization misses backslash traversal, so a Windows-style path could escape docs/ on a Windows build. Reject backslashes and both POSIX and Windows absolute forms, keeping the normalized `..` traversal check.
1 parent 0093ecf commit efe8dc6

1 file changed

Lines changed: 10 additions & 3 deletions

File tree

scripts/bundleSdkDocs.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,10 +76,17 @@ async function bundleSdkDocs() {
7676
let copied = 0;
7777

7878
for (const rel of manifest) {
79-
// Defensive: nav paths come from our own docs.json, but a fat-fingered `../` entry
80-
// shouldn't be able to copy a file from outside docs/ into the package.
79+
// Defensive: nav paths come from our own docs.json and are URL-style, but a
80+
// fat-fingered `../`, a backslash, or an absolute path shouldn't be able to copy a
81+
// file from outside docs/ into the package. Reject backslashes (Windows separator)
82+
// and both POSIX and Windows absolute forms, then the normalized `..` traversal.
8183
const safeRel = path.posix.normalize(rel);
82-
if (path.isAbsolute(safeRel) || safeRel.startsWith("..")) {
84+
if (
85+
rel.includes("\\") ||
86+
path.posix.isAbsolute(rel) ||
87+
path.win32.isAbsolute(rel) ||
88+
safeRel.startsWith("..")
89+
) {
8390
throw new Error(`[bundleSdkDocs] invalid nav path "${rel}" under "${DROPDOWN}"`);
8491
}
8592

0 commit comments

Comments
 (0)