Severity:

HIGH RISK

(7.3)

Code Injection / Dynamic Code Evaluation in MetaGPT XML

CVE-2026-5971

Analyzed

Vulnerability type

Category:

Code Injection / Dynamic Code Evaluation

CWE:

CWE-94, CWE-95

Impact:

Remote Code Execution

Severity:

HIGH RISK

(7.3)

CVSS version:

3.1

Catch this CVE while code is being written

Detect vulnerable code directly in pull requests, so CVEs are fixed before merge.

Summary

MetaGPT up to version 0.8.1 contains a code injection flaw in the XML Handler's ActionNode.xml_fill function, where XML-driven directives are insufficiently sanitized before being dynamically evaluated.

When an attacker can influence XML content processed by this component, they may execute arbitrary code remotely in the context of the MetaGPT process.

Affected context

This vulnerability occurs in MetaGPT deployments that process XML-based action definitions through the ActionNode.xml_fill function within metagpt/actions/action_node.py.

It is relevant in scenarios where:

  • XML content is accepted from external or semi-trusted sources (e.g., user input, integrations, or remote workflows), and
  • That XML can influence code-like directives or expressions that are dynamically interpreted or evaluated.

The risk is elevated when MetaGPT runs with broad system permissions or has access to sensitive data or downstream systems.

Exploit preconditions

  • Attack surface: Remote, via any interface or integration that allows attackers to supply or alter XML consumed by ActionNode.xml_fill.
  • Required access: Capability to submit, inject, or modify XML payloads that are processed by the XML Handler (e.g., via API endpoints, plugins, or message channels).
  • Trigger point: XML-driven directives are parsed and used as input to dynamic code evaluation logic without sufficient neutralization of dangerous constructs.
  • Why exploitation is possible: Untrusted XML data is treated as trusted code or code-like directives, allowing attacker-controlled content to be executed in the interpreter, mapping to CWE-94/CWE-95.

Why this happens

The root cause is the use of dynamic code evaluation mechanisms (such as eval, exec, or equivalent meta-programming features) on values derived from XML content without rigorous sanitization, whitelisting, or structural validation.

ActionNode.xml_fill appears to interpret XML-sourced directives as executable logic, failing to neutralize or restrict dangerous characters, operators, or language constructs.

Conceptually, this matches CWE-94: Improper Control of Generation of Code ('Code Injection') and CWE-95: Improper Neutralization of Directives in Dynamically Evaluated Code, where attacker-controlled text is turned into executable code, breaking the boundary between data and code.

Potential impact

  • Execution of arbitrary code with the privileges of the MetaGPT service.
  • Access to and exfiltration of sensitive data, prompts, and outputs handled by MetaGPT.
  • Manipulation of MetaGPT workflows, responses, or downstream automated actions (e.g., task automation, integrations).
  • Pivoting to other systems reachable from the host, including lateral movement within the environment.
  • Service disruption, data corruption, or deployment of malware via the compromised runtime.

General mitigation guidance

Effective mitigation focuses on treating XML content strictly as data and eliminating direct dynamic evaluation of XML-derived directives:

  • Replace general-purpose dynamic evaluation (eval, exec, template engines with arbitrary expressions) with explicit, declarative command sets or configuration schemas.
  • Introduce strict whitelisting of allowable operations and arguments; map XML tags/attributes to predefined, non-interpreted handlers.
  • Apply robust input validation and canonicalization on XML fields before they influence any execution path, rejecting unexpected tokens, operators, or embedded code.
  • Use safe parsing and binding patterns (e.g., mapping to typed data structures) rather than code construction or interpretation.
  • Run MetaGPT with least privilege, isolating it via containers, sandboxing, or restricted OS-level permissions to limit damage if code execution occurs.

How teams detect issues like this

Organizations can look for this class of vulnerability and its abuse using:

  • Static analysis: Rules that flag use of eval, exec, or similar dynamic evaluation APIs where arguments originate from XML parsing or other external input sources.
  • Code review: Focused reviews of XML handling components and utility functions that transform parsed XML into executable logic, templates, or scripting constructs.
  • Logging and runtime monitoring: Enhanced logging around XML ingestion and directive processing, with alerts for anomalous or unexpectedly complex directive content.
  • Policy enforcement: Development policies and CI checks that forbid unreviewed introduction of dynamic evaluation mechanisms, requiring documented justification and guards when they are used.

Sources

SourceLink
github.comgithub.com/FoundationAgents/MetaGPT/
github.comgithub.com/FoundationAgents/MetaGPT/issues/1928
github.comgithub.com/FoundationAgents/MetaGPT/issues/1956
vuldb.comvuldb.com/submit/791734
vuldb.comvuldb.com/vuln/356525
vuldb.comvuldb.com/vuln/356525/cti

Frequently asked

questions

Yes, it can be remotely exploitable if attackers can submit or influence XML data that the MetaGPT XML Handler processes. Any remote interface that accepts XML and passes it through ActionNode.xml_fill without additional safeguards could be an entry point.

The attacker needs the ability to provide or manipulate XML content consumed by the vulnerable component. They do not necessarily need authenticated access if any exposed endpoint, integration, or pipeline accepts XML from untrusted sources.

The safest approach is to remove or strictly limit dynamic code evaluation on XML-derived values. Instead, use a constrained, declarative representation where XML fields map to predefined operations or parameters, validated against a schema, and never executed as arbitrary code.

Avoid mixing data with code by design. Prohibit unsafe dynamic evaluation of user-controlled input, enforce secure coding guidelines that discourage eval/exec, apply schema-based validation for structured formats like XML, and integrate static analysis plus security-focused code reviews into the development workflow.

Find out what's already
exploitable in your codebase.