VAITP Dataset

← Back to the dataset

CVE-2026-33235

AutoGPT is vulnerable to DoS via complex expressions in the text template.

  • CVSS 7.7
  • CWE-400
  • Resource Management
  • Remote

AutoGPT is a workflow automation platform for creating, deploying, and managing continuous artificial intelligence agents. In versions prior to 0.6.52, the Fill Text Template block is vulnerable to a Denial of Service (DoS) attack. While the backend implements a SandboxedEnvironment to prevent unauthorized attribute access (e.g., blocking __class__), it fails to limit the computational complexity or execution time of the expressions. An attacker can input computationally expensive Python/Jinja2 expressions that consume the server's CPU and memory, leading to a complete system hang or crash. In multi-tenant or self-hosted environments, this results in a complete service outage and "noisy neighbor" effects that require manual administrative intervention to recover. This issue has been fixed in version 0.6.52.

CVSS base score
7.7
Published
2026-06-24
OWASP
A04 Insecure Design
Orthogonal defect classification
Checking
Code defect classification
Missing Check
Category
Resource Management
Subcategory
Resource Exhaustion
Accessibility scope
Remote
Impact
Denial of Service (DoS)
Affected component
AutoGPT
Fixed by upgrading
Yes

Solution

Upgrade to AutoGPT version 0.6.52 or later.

Vulnerable code sample

import jinja2
import sys

# In a real-world scenario, this input would come from an untrusted user,
# for example, through a web API endpoint.
# This payload creates a huge list in memory, consuming all available RAM and CPU.
# A slightly more complex payload could involve nested loops or complex calculations.
user_provided_template = "{{ '*' * (99999999) }}"

def process_user_template(template_string: str):
    """
    Simulates the vulnerable 'Fill Text Template' block.
    It uses a SandboxedEnvironment, which prevents access to dangerous
    attributes like `__class__`, but does not limit execution time or
    computational resources.
    """
    print("Attempting to render user-provided template...")
    sys.stdout.flush()
    try:
        # The environment is sandboxed to prevent access to unsafe attributes.
        env = jinja2.SandboxedEnvironment()
        
        # However, no limits are placed on CPU or memory usage.
        template = env.from_string(template_string)
        
        # This line will hang or crash as it tries to evaluate the expensive expression.
        result = template.render()
        
        print("Template rendered successfully (this message will not be reached).")
        return result
    except Exception as e:
        # This exception handler may not even be reached if the process is killed
        # by the OS for excessive resource consumption.
        print(f"An exception occurred: {e}")
        return None

if __name__ == "__main__":
    # This call demonstrates the vulnerability.
    # The script will become unresponsive and consume 100% CPU and a large
    # amount of memory until it is manually terminated or crashes.
    process_user_template(user_provided_template)

Patched code sample

import jinja2
import signal
from contextlib import contextmanager

# The vulnerability is that Jinja2's SandboxedEnvironment does not limit
# the execution time or computational complexity of the expressions it renders.
# An attacker can submit a template that performs a very long calculation,
# causing a Denial of Service (DoS) by consuming 100% CPU.

# The fix is to wrap the template rendering process in a timeout, which
# aborts the operation if it takes too long. This example uses Python's
# built-in signal library to achieve this.

EXECUTION_TIMEOUT_SECONDS = 2

class TimeoutException(Exception):
    """Custom exception to be raised on timeout."""
    pass

@contextmanager
def time_limit(seconds):
    """
    A context manager to enforce a time limit on a block of code.
    Raises TimeoutException if the code does not complete in time.
    NOTE: This is a Unix-specific solution using signals.
    """
    def signal_handler(signum, frame):
        raise TimeoutException(f"Timed out after {seconds} seconds.")

    # Set the signal handler for the alarm signal (SIGALRM)
    original_handler = signal.signal(signal.SIGALRM, signal_handler)
    
    try:
        # Schedule the alarm
        signal.alarm(seconds)
        yield
    finally:
        # Cancel the alarm and restore the original signal handler
        signal.alarm(0)
        signal.signal(signal.SIGALRM, original_handler)

def render_template_safely(template_string: str, data: dict) -> str:
    """
    Renders a Jinja2 template within a strict time limit to prevent DoS.
    """
    env = jinja2.SandboxedEnvironment()
    
    try:
        # Use the time_limit context manager to enforce the timeout
        with time_limit(EXECUTION_TIMEOUT_SECONDS):
            template = env.from_string(template_string)
            return template.render(data)
    except TimeoutException as e:
        # The rendering took too long and was aborted.
        return f"Error: Rendering aborted. {e}"
    except Exception as e:
        # Catch other potential Jinja2 or rendering errors
        return f"Error: An unexpected error occurred during rendering: {e}"

if __name__ == "__main__":
    # Example 1: Benign template that runs quickly
    benign_template = "Hello, {{ name }}! Your lucky number is {{ 5*5 }}."
    benign_data = {"name": "World"}
    print("--- Testing benign template ---")
    result = render_template_safely(benign_template, benign_data)
    print(f"Result: {result}\n")

    # Example 2: Malicious template designed to cause a long-running calculation
    # This attempts to create a huge list, consuming CPU time.
    malicious_template = """
    {% set _ = [] %}
    {% for i in range(10**8) %}
      {% set _ = _.append(i) %}
    {% endfor %}
    This will never be seen.
    """
    print("--- Testing malicious DoS template ---")
    result = render_template_safely(malicious_template, {})
    print(f"Result: {result}")
    print("DoS attack was successfully prevented by the timeout.")

Payload

{{ 99999999**99999999 }}

Cite this entry

@misc{vaitp:cve202633235,
  title        = {{AutoGPT is vulnerable to DoS via complex expressions in the text template.}},
  author       = {Bogaerts, Fr\'ed\'eric and Ivaki, Naghmeh and Fonseca, Jos\'e},
  year         = {2026},
  note         = {VAITP Python Vulnerability Dataset, entry CVE-2026-33235},
  howpublished = {\url{https://netpack.pt/vaitp/vulnerability/CVE-2026-33235/}}
}
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 ::