CVE-2026-0761
MetaGPT actionoutput_str_to_mapping unauthenticated code injection RCE.
- CVSS 9.8
- CWE-94
- Input Validation and Sanitization
- Remote
Foundation Agents MetaGPT actionoutput_str_to_mapping Code Injection Remote Code Execution Vulnerability. This vulnerability allows remote attackers to execute arbitrary code on affected installations of Foundation Agents MetaGPT. Authentication is not required to exploit this vulnerability. The specific flaw exists within the actionoutput_str_to_mapping function. The issue results from the lack of proper validation of a user-supplied string before using it to execute Python code. An attacker can leverage this vulnerability to execute code in the context of the service account. Was ZDI-CAN-28124.
- CWE
- CWE-94
- CVSS base score
- 9.8
- Published
- 2026-01-23
- 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
- Foundation A
- Fixed by upgrading
- Yes
Solution
Upgrade to MetaGPT version 0.9.1 or later.
Vulnerable code sample
from typing import Dict
def actionoutput_str_to_mapping(action_output_str: str) -> Dict[str, str]:
"""Converts a string representation of a dictionary into a dictionary object."""
return eval(action_output_str)Patched code sample
import ast
def actionoutput_str_to_mapping(output_str: str) -> dict:
"""
Safely parses an action output string into a dictionary.
This function replaces a dangerous `eval()` call with `ast.literal_eval`
to prevent remote code execution. It ensures that only valid Python
literals (like dictionaries) are evaluated, not arbitrary code.
"""
if not isinstance(output_str, str):
return {}
try:
# ast.literal_eval safely parses a string containing a Python literal
# structure (e.g., dicts, lists, strings, numbers). It does not
# compile or execute arbitrary code, mitigating the injection vulnerability.
parsed_object = ast.literal_eval(output_str)
if isinstance(parsed_object, dict):
return parsed_object
else:
# The input was a valid literal but not the expected dictionary type.
# Return an empty dict to handle this gracefully.
return {}
except (ValueError, SyntaxError, MemoryError, TypeError):
# The input string is not a valid Python literal.
# Catch exceptions to prevent the service from crashing on malformed input
# and return an empty dictionary.
return {}Payload
{"result": __import__('os').system('id')}
Cite this entry
@misc{vaitp:cve20260761,
title = {{MetaGPT actionoutput_str_to_mapping unauthenticated code injection RCE.}},
author = {Bogaerts, Fr\'ed\'eric and Ivaki, Naghmeh and Fonseca, Jos\'e},
year = {2026},
note = {VAITP Python Vulnerability Dataset, entry CVE-2026-0761},
howpublished = {\url{https://netpack.pt/vaitp/vulnerability/CVE-2026-0761/}}
}
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 ::
