VAITP Dataset

← Back to the dataset

CVE-2026-42079

PPTAgent allows arbitrary code execution via eval() of LLM-generated code.

  • CVSS 8.6
  • CWE-95
  • Input Validation and Sanitization
  • Local

PPTAgent is an agentic framework for reflective PowerPoint generation. Prior to commit 418491a, PPTAgent is vulnerable to arbitrary code execution via Python eval() of LLM-generated code with builtins in scope. This issue has been patched via commit 418491a.

CVSS base score
8.6
Published
2026-05-04
OWASP
A03 Injection
Orthogonal defect classification
Checking
Code defect classification
Missing Check
Category
Input Validation and Sanitization
Subcategory
Command Injection
Accessibility scope
Local
Impact
Arbitrary Code Execution
Affected component
PPTAgent
Fixed by upgrading
Yes

Solution

Update to commit 418491a or a later version.

Vulnerable code sample

def execute_llm_action(code_from_llm: str):
    """
    Simulates the agent executing a Python expression generated by an LLM.
    This is intended to perform simple, sandboxed actions.
    """
    # VULNERABLE: The code_from_llm, which comes from an external and
    # untrusted source (the LLM), is executed directly using eval().
    # The default globals() for eval() include the 'builtins' module,
    # which contains dangerous functions like `__import__`.
    # A malicious payload like "__import__('os').system('id')" would be
    # executed with the permissions of the running process.
    result = eval(code_from_llm)
    return result

Patched code sample

import os

# Mock functions that would interact with a PowerPoint library
def add_slide(title, content):
    """A safe function to add a slide."""
    print(f"[ACTION] Adding slide with title: '{title}' and content: '{content}'")
    return {"status": "success", "slide_id": 1}

def set_background_color(slide_id, color):
    """A safe function to set a slide's background color."""
    print(f"[ACTION] Setting background of slide {slide_id} to {color}")
    return {"status": "success"}

def safe_execute_llm_code(code_string: str):
    """
    This function represents the fix for the vulnerability.
    It executes LLM-generated code by providing a restricted scope to eval(),
    preventing access to dangerous built-in functions.
    """
    # 1. Define an "allowlist" of safe functions the LLM can call.
    safe_api = {
        "add_slide": add_slide,
        "set_background_color": set_background_color,
    }

    # 2. Create the restricted globals dictionary for eval().
    # The crucial part of the fix is replacing '__builtins__' with a
    # dictionary containing only functions considered safe (or an empty one).
    # This prevents the LLM code from accessing dangerous builtins
    # like `__import__`, `open()`, or `exec()`.
    safe_globals = {
        "__builtins__": {
            "print": print, # Example of allowing a single, safe builtin
            "dict": dict,
            "list": list
        },
        **safe_api
    }

    try:
        # 3. Execute the code using eval() with the restricted scope.
        # Any attempt to call a function not in `safe_globals` will fail.
        print(f"Executing code: {code_string}")
        eval(code_string, safe_globals, {})
        print("Execution successful and safe.\n")
    except Exception as e:
        print(f"Execution blocked. Reason: {e}\n")


if __name__ == '__main__':
    # --- VULNERABLE APPROACH (for demonstration) ---
    # This is what an attacker might try. The LLM could be prompted
    # to generate a malicious string like this.
    malicious_code = "__import__('os').system('echo VULNERABILITY EXPLOITED!')"

    print("--- Simulating VULNERABLE execution (unsafe eval) ---")
    try:
        # In the vulnerable version, eval() has access to all builtins.
        eval(malicious_code)
    except Exception as e:
        print(f"An error occurred: {e}")
    print("-" * 50)


    # --- FIXED APPROACH ---
    print("--- Simulating FIXED execution (safe_execute_llm_code) ---")

    # Example 1: Benign code generated by the LLM. This will work.
    benign_code = "add_slide(title='Introduction', content='Hello World')"
    safe_execute_llm_code(benign_code)

    # Example 2: Malicious code generated by the LLM. This will be blocked.
    safe_execute_llm_code(malicious_code)

Payload

__import__('os').system('touch /tmp/pwned')

Cite this entry

@misc{vaitp:cve202642079,
  title        = {{PPTAgent allows arbitrary code execution via eval() of LLM-generated code.}},
  author       = {Bogaerts, Fr\'ed\'eric and Ivaki, Naghmeh and Fonseca, Jos\'e},
  year         = {2026},
  note         = {VAITP Python Vulnerability Dataset, entry CVE-2026-42079},
  howpublished = {\url{https://netpack.pt/vaitp/vulnerability/CVE-2026-42079/}}
}
Introducing the "VAITP dataset": a specialized repository of Python vulnerabilities and patches, meticulously compiled for the use of the security research community. As Python's prominence grows, understanding and addressing potential security vulnerabilities become crucial. Crafted by and for the cybersecurity community, this dataset offers a valuable resource for researchers, analysts, and developers to analyze and mitigate the security risks associated with Python. Through the comprehensive exploration of vulnerabilities and corresponding patches, the VAITP dataset fosters a safer and more resilient Python ecosystem, encouraging collaborative advancements in programming security.

The supreme art of war is to subdue the enemy without fighting.

Sun Tzu – “The Art of War”

:: Shaping the future through research and ingenuity ::