CVE-2026-35002
Agno remote code execution via eval() injection in the field_type parameter.
- CVSS 9.3
- CWE-95
- Input Validation and Sanitization
- Remote
Agno versions prior to 2.3.24 contain an arbitrary code execution vulnerability in the model execution component that allows attackers to execute arbitrary Python code by manipulating the field_type parameter passed to eval(). Attackers can influence the field_type value in a FunctionCall to achieve remote code execution.
- CWE
- CWE-95
- CVSS base score
- 9.3
- Published
- 2026-04-02
- OWASP
- A03 Injection
- Orthogonal defect classification
- Checking
- Code defect classification
- Missing Check
- Category
- Input Validation and Sanitization
- Subcategory
- Command Injection
- Accessibility scope
- Remote
- Impact
- Arbitrary Code Execution
- Affected component
- Agno
- Fixed by upgrading
- Yes
Solution
Upgrade to Agno version 2.3.24 or newer.
Vulnerable code sample
import os
class ModelExecutor:
"""
A hypothetical component representing the 'Agno' model execution engine.
This class contains the vulnerable code as it might have existed before a fix.
"""
def execute_function(self, function_call: dict):
"""
Executes a function based on a dictionary-defined call.
The 'field_type' parameter from the call is used to dynamically
resolve a type for casting a value.
"""
field_type_str = function_call.get('field_type')
value = function_call.get('value')
if not field_type_str:
raise ValueError("The 'field_type' parameter is missing.")
# VULNERABILITY: The user-controlled 'field_type_str' is passed directly
# to the eval() function. An attacker can craft this string to execute
# arbitrary Python code on the server.
resolved_type = eval(field_type_str)
# The intended, non-malicious functionality was likely to cast the value
# to the specified type, e.g., using eval('int') to get the int class.
try:
processed_value = resolved_type(value)
print(f"Successfully processed value: {processed_value}")
return {"status": "success", "result": processed_value}
except TypeError:
# This error might occur after the malicious code has already executed.
# For example, if the payload is os.system(...), it returns an int,
# which is not a callable type constructor, raising a TypeError.
print("Error: The resolved type was not a callable constructor.")
return {"status": "error", "message": "Post-execution type error"}Patched code sample
import os
# --- The Fix for a vulnerability like CVE-2026-35002 ---
# The vulnerability stems from using eval() on user-controllable input.
# The fix is to replace the dangerous eval() call with a safe lookup
# mechanism, such as a dictionary acting as an allow-list (safelist).
# 1. Define a safelist of allowed, primitive types.
# This ensures that only expected and safe type names are processed.
ALLOWED_TYPES = {
'str': str,
'int': int,
'float': float,
'bool': bool,
}
def fixed_model_executor(function_call):
"""
A corrected version of a model execution component that is not
vulnerable to arbitrary code execution.
"""
processed_args = {}
arguments = function_call.get('arguments', [])
for arg in arguments:
field_type_str = arg.get('field_type')
value = arg.get('value')
arg_name = arg.get('name')
# --- VULNERABILITY MITIGATION ---
# Instead of using eval(field_type_str), we safely look up the
# type in our predefined safelist.
type_class = ALLOWED_TYPES.get(field_type_str)
if type_class is None:
# If the provided field_type is not in our safelist, we
# reject it and raise an error, preventing the attack.
raise TypeError(f"Unsupported or malicious field_type: '{field_type_str}'")
try:
# Safely cast the value to the allowed type.
processed_args[arg_name] = type_class(value)
print(f"Successfully processed argument '{arg_name}' with value '{value}' as type {type_class.__name__}")
except (ValueError, TypeError):
raise ValueError(f"Could not cast value '{value}' to type {field_type_str}")
return processed_args
# --- Demonstration ---
if __name__ == '__main__':
# A legitimate call that should be processed correctly.
legitimate_function_call = {
'name': 'update_user',
'arguments': [
{'name': 'user_id', 'value': '12345', 'field_type': 'int'},
{'name': 'is_active', 'value': 'True', 'field_type': 'bool'}
]
}
print("--- Testing with legitimate input ---")
try:
result = fixed_model_executor(legitimate_function_call)
print(f"Success. Processed arguments: {result}\n")
except (TypeError, ValueError) as e:
print(f"An unexpected error occurred: {e}\n")
# A malicious call attempting to execute arbitrary code.
# The 'field_type' contains a payload that would be executed by eval().
malicious_function_call = {
'name': 'exploit',
'arguments': [{
'name': 'payload',
'value': 'ignored',
'field_type': "__import__('os').system('echo VULNERABILITY EXPLOITED')"
}]
}
print("--- Testing with malicious input ---")
try:
fixed_model_executor(malicious_function_call)
except (TypeError, ValueError) as e:
# The expected outcome: The fixed code catches the malicious 'field_type'
# and raises a TypeError instead of executing the payload.
print(f"Attack blocked. The code raised the following error as expected: {e}")Payload
__import__('os').system('id')
Cite this entry
@misc{vaitp:cve202635002,
title = {{Agno remote code execution via eval() injection in the field_type parameter.}},
author = {Bogaerts, Fr\'ed\'eric and Ivaki, Naghmeh and Fonseca, Jos\'e},
year = {2026},
note = {VAITP Python Vulnerability Dataset, entry CVE-2026-35002},
howpublished = {\url{https://netpack.pt/vaitp/vulnerability/CVE-2026-35002/}}
}
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 ::
