{"answers":{"affected":"3 open source packages ship an affected version, including llama-cpp-python.","exploited":"It is not confirmed as exploited in the wild, but public exploit code for CVE-2024-34359 exists.","fix":"Upgrade llama-cpp-python to 0.2.72 or later.","what":"CVE-2024-34359 is a critical code injection vulnerability in abetlen llama-cpp-python, published on 10 May 2024. An attacker can exploit it over the internet without logging in, and only if a user opens a file or follows a link."},"fix_prompt":"Check this codebase for CVE-2024-34359 and fix it if it is affected.\n\nWhat it is: CVE-2024-34359 is a critical code injection vulnerability in abetlen llama-cpp-python, published on 10 May 2024. An attacker can exploit it over the internet without logging in, and only if a user opens a file or follows a link.\nExploitation: It is not confirmed as exploited in the wild, but public exploit code for CVE-2024-34359 exists.\n\nAffected packages and fixed versions:\n- llama-cpp-python (PyPI): affected from 0.2.30; fixed in 0.2.72\n- llama-cpp-python (PyPI): affected from 0.2.30; fixed in 0.2.72\n- llama-cpp-python (PyPI): affected from 0.2.30; fixed in 0.2.72\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-2024-34359/ (Markdown: https://insights.sbomify.com/CVE-2024-34359/index.md)","id":"CVE-2024-34359","markdown":"https://insights.sbomify.com/CVE-2024-34359/index.md","name":"CVE-2024-34359","record":{"aliases":["GHSA-56xg-wfcc-g829","PYSEC-2026-392"],"analysis":{"component_type":"library","fix_type":"upgrade","impacts":["code_execution"],"network_reachable":"yes","non_default_config":false,"product_category":"Python LLM bindings","requires_auth":"none","summary":"Attackers can execute arbitrary code by providing a malicious GGUF model file with a crafted Jinja2 chat template in its metadata.","user_interaction":"required","vuln_class":"code_injection"},"analysis_generated_by":"qwen3.8-flash-next","assigner":"GitHub_M","cpe":[],"cvss":{"score":9.7,"severity":"critical","source":"cna","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:H/I:H/A:H","version":"3.1"},"cwes":[{"id":"CWE-76","name":"Improper Neutralization of Equivalent Special Elements"}],"description":"llama-cpp-python is the Python bindings for llama.cpp. `llama-cpp-python` depends on class `Llama` in `llama.py` to load `.gguf` llama.cpp or Latency Machine Learning Models. The `__init__` constructor built in the `Llama` takes several parameters to configure the loading and running of the model. Other than `NUMA, LoRa settings`, `loading tokenizers,` and `hardware settings`, `__init__` also loads the `chat template` from targeted `.gguf` 's Metadata and furtherly parses it to `llama_chat_format.Jinja2ChatFormatter.to_chat_handler()` to construct the `self.chat_handler` for this model. Nevertheless, `Jinja2ChatFormatter` parse the `chat template` within the Metadate with sandbox-less `jinja2.Environment`, which is furthermore rendered in `__call__` to construct the `prompt` of interaction. This allows `jinja2` Server Side Template Injection which leads to remote code execution by a carefully constructed payload.","ecosystems":["PyPI"],"exploits":{"exploitdb":0,"first_seen":null,"github_poc":0,"max_poc_stars":null,"metasploit":0,"nuclei":0,"refs":[],"tier":"weaponised"},"has_fix":true,"headline":"llama-cpp-python vulnerable to Remote Code Execution by Server-Side Template Injection in Model Metadata","id":"CVE-2024-34359","indexable":true,"kev":null,"kind":"cve","links":{"ecosystem":"PyPI","product":null,"products":[],"type":"code_injection","year":"2024"},"n_packages":3,"n_references":2,"next":{"headline":"Previous ATX is not checked to be the newest valid ATX by Smesher when validating incoming ATX","id":"CVE-2024-34360"},"packages":[{"ecosystem":"PyPI","fixed":["0.2.72"],"introduced":["0.2.30"],"last_affected":[],"package":"llama-cpp-python","purl":null,"source":"GHSA-56xg-wfcc-g829"},{"ecosystem":"PyPI","fixed":["0.2.72"],"introduced":["0.2.30"],"last_affected":[],"package":"llama-cpp-python","purl":"pkg:pypi/llama-cpp-python","source":"GHSA-56xg-wfcc-g829"},{"ecosystem":"PyPI","fixed":["0.2.72"],"introduced":["0.2.30"],"last_affected":[],"package":"llama-cpp-python","purl":"pkg:pypi/llama-cpp-python","source":"PYSEC-2026-392"}],"prev":{"headline":"TYPO3 vulnerable to an Uncontrolled Resource Consumption in the ShowImageController","id":"CVE-2024-34358"},"products":["llama-cpp-python"],"published":"2024-05-10","related":[],"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":"CWE Terms of Use","name":"CWE (MITRE)"},{"class":"attribution","licence":"FIRST CVSS licence","name":"CVSS (FIRST)"}],"ssvc":{"automatable":"no","exploitation":"poc","technical_impact":"total"},"state":"PUBLISHED","updated":"2024-08-02","vendors":["abetlen"]},"summary":"Attackers can execute arbitrary code by providing a malicious GGUF model file with a crafted Jinja2 chat template in its metadata.","url":"https://insights.sbomify.com/CVE-2024-34359/"}