{"answers":{"affected":"6 open source packages ship an affected version, including restrictedpython and RestrictedPython. It affects 1 product.","exploited":"There is no known exploitation of CVE-2023-37271 in the wild and no public exploit code.","fix":"Upgrade restrictedpython to a fixed version for your release line: 5.3 or 6.1.","what":"CVE-2023-37271 is a high-severity code injection vulnerability in zopefoundation RestrictedPython, published on 11 Jul 2023. Any signed-in user can exploit it over the network, with no action from the victim."},"fix_prompt":"Check this codebase for CVE-2023-37271 and fix it if it is affected.\n\nWhat it is: CVE-2023-37271 is a high-severity code injection vulnerability in zopefoundation RestrictedPython, published on 11 Jul 2023. Any signed-in user can exploit it over the network, with no action from the victim.\nExploitation: There is no known exploitation of CVE-2023-37271 in the wild and no public exploit code.\n\nAffected packages and fixed versions:\n- restrictedpython (PyPI): affected all versions; fixed in 5.3\n- restrictedpython (PyPI): affected all versions; fixed in 5.3\n- restrictedpython (PyPI): affected all versions; fixed in 5.3\n- restrictedpython (PyPI): affected from 6.0a1.dev0; fixed in 6.1\n- RestrictedPython (PyPI): affected all versions; fixed in 5.3\n- RestrictedPython (PyPI): affected from 6.0a1.dev0; fixed in 6.1\n\nTask:\n1. Search the dependency manifests and lockfiles (for example package.json, package-lock.json, requirements.txt, poetry.lock, uv.lock, pom.xml, build.gradle, go.mod, Cargo.lock, Gemfile.lock) and any Dockerfiles for the affected packages, including transitive dependencies.\n2. If an affected version is in use, upgrade it to the fixed version for its release line with the project's package manager, so the lockfile is regenerated. Prefer the smallest upgrade that fixes it.\n3. If there is no fix, or the upgrade would break the build, do not guess: explain the risk and the safest workaround instead.\n4. Run the tests and summarise what changed and why.\n5. If nothing in the project is affected, say so and change nothing.\n\nReference: https://insights.sbomify.com/CVE-2023-37271/ (Markdown: https://insights.sbomify.com/CVE-2023-37271/index.md)","id":"CVE-2023-37271","markdown":"https://insights.sbomify.com/CVE-2023-37271/index.md","name":"CVE-2023-37271","record":{"aliases":["DEBIAN-CVE-2023-37271","GHSA-wqc8-x2pr-7jqh","PYSEC-2023-118","UBUNTU-CVE-2023-37271"],"analysis":{"component_type":"library","fix_type":"upgrade","impacts":["code_execution"],"network_reachable":"yes","non_default_config":true,"product_category":"Python sandbox library","requires_auth":"low_privilege","summary":"Attackers can escape the RestrictedPython sandbox via stack frame access to execute arbitrary code, affecting deployments allowing untrusted Python code.","user_interaction":"not_required","vuln_class":"code_injection"},"analysis_generated_by":"qwen3.8-flash-next","assigner":"GitHub_M","cpe":[{"product":"restrictedpython","vendor":"zope"}],"cvss":{"score":8.4,"severity":"high","source":"cna","vector":"CVSS:3.1/AV:N/AC:H/PR:L/UI:N/S:C/C:H/I:H/A:L","version":"3.1"},"cwes":[{"id":"CWE-913","name":"Improper Control of Dynamically-Managed Code Resources"}],"description":"RestrictedPython is a tool that helps to define a subset of the Python language which allows users to provide a program input into a trusted environment. RestrictedPython does not check access to stack frames and their attributes. Stack frames are accessible within at least generators and generator expressions, which are allowed inside RestrictedPython. Prior to versions 6.1 and 5.3, an attacker with access to a RestrictedPython environment can write code that gets the current stack frame in a generator and then walk the stack all the way beyond the RestrictedPython invocation boundary, thus breaking out of the restricted sandbox and potentially allowing arbitrary code execution in the Python interpreter. All RestrictedPython deployments that allow untrusted users to write Python code in the RestrictedPython environment are at risk. In terms of Zope and Plone, this would mean deployments where the administrator allows untrusted users to create and/or edit objects of type `Script (Python)`, `DTML Method`, `DTML Document` or `Zope Page Template`. This is a non-default configuration and likely to be extremely rare. The problem has been fixed in versions 6.1 and 5.3.","ecosystems":["PyPI"],"exploits":{"exploitdb":0,"first_seen":null,"github_poc":0,"max_poc_stars":null,"metasploit":0,"nuclei":0,"refs":[],"tier":"none_known"},"has_fix":true,"headline":"RestrictedPython vulnerable to arbitrary code execution via stack frame sandbox escape","id":"CVE-2023-37271","indexable":true,"kev":null,"kind":"cve","links":{"ecosystem":"PyPI","product":null,"products":[],"type":"code_injection","year":"2023"},"n_packages":6,"n_references":2,"next":{"headline":"XSS vulnerability in JOC Cockpit branch 1.13","id":"CVE-2023-37272"},"packages":[{"ecosystem":"PyPI","fixed":["5.3"],"introduced":["0"],"last_affected":[],"package":"RestrictedPython","purl":null,"source":"GHSA-wqc8-x2pr-7jqh"},{"ecosystem":"PyPI","fixed":["6.1"],"introduced":["6.0a1.dev0"],"last_affected":[],"package":"RestrictedPython","purl":null,"source":"GHSA-wqc8-x2pr-7jqh"},{"ecosystem":"PyPI","fixed":["5.3"],"introduced":["0"],"last_affected":[],"package":"restrictedpython","purl":null,"source":"GHSA-wqc8-x2pr-7jqh"},{"ecosystem":"PyPI","fixed":["5.3"],"introduced":["0"],"last_affected":[],"package":"restrictedpython","purl":"pkg:pypi/restrictedpython","source":"GHSA-wqc8-x2pr-7jqh"},{"ecosystem":"PyPI","fixed":["5.3"],"introduced":["0"],"last_affected":[],"package":"restrictedpython","purl":"pkg:pypi/restrictedpython","source":"PYSEC-2023-118"},{"ecosystem":"PyPI","fixed":["6.1"],"introduced":["6.0a1.dev0"],"last_affected":[],"package":"restrictedpython","purl":"pkg:pypi/restrictedpython","source":"GHSA-wqc8-x2pr-7jqh"}],"prev":{"headline":"Piwigo SQL Injection vulnerability in \"User-Agent\"","id":"CVE-2023-37270"},"products":["RestrictedPython"],"published":"2023-07-11","related":[{"cvss_score":8.7,"headline":"RestrictedPython information leakage via `AttributeError.obj` and the `string` module","id":"CVE-2024-47532","kev_date_added":null,"published":"2024-09-30"},{"cvss_score":8.3,"headline":"Sandbox escape via various forms of \"format\" in RestrictedPython","id":"CVE-2023-41039","kev_date_added":null,"published":"2023-08-30"}],"sources":[{"class":"attribution","licence":"CVE Terms of Use (MITRE)","name":"CVE List","prefix":"CVE"},{"class":"attribution","licence":"CC BY 4.0","name":"GitHub Advisory Database","prefix":"GHSA"},{"class":"attribution","licence":"CC BY 4.0","name":"PyPA Advisory Database","prefix":"PYSEC"},{"class":"attribution","licence":"US public information, NVD API terms","name":"NVD"},{"class":"attribution","licence":"CWE Terms of Use","name":"CWE (MITRE)"},{"class":"attribution","licence":"FIRST CVSS licence","name":"CVSS (FIRST)"}],"ssvc":{"automatable":"no","exploitation":"none","technical_impact":"total"},"state":"PUBLISHED","updated":"2024-11-07","vendors":["zopefoundation"]},"summary":"Attackers can escape the RestrictedPython sandbox via stack frame access to execute arbitrary code, affecting deployments allowing untrusted Python code.","url":"https://insights.sbomify.com/CVE-2023-37271/"}