/

CVE-2026-54769

Severity:

CRITICAL RISK

(10.0)

Code Injection (CWE-94) in Langroid LLM Tooling APIs

CVE-2026-54769

Deferred

Vulnerability type

Category:

Code Injection

CWE:

CWE-94

Impact:

Remote Code Execution

Severity:

CRITICAL RISK

(10.0)

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

Langroid's TableChatAgent and VectorStore components contain a critical code injection flaw in how they evaluate LLM-generated tool messages using Python's eval() with incomplete sandboxing.

When full_eval=True, an attacker who can influence prompts or LLM output can execute arbitrary OS commands on the host by abusing implicitly available Python built-ins.

Affected context

This vulnerability appears in Langroid-based applications that:

  • Use TableChatAgent.pandas_eval() and/or VectorStore evaluation helpers
  • Enable full_eval=True for LLM-generated tool messages or expressions
  • Run these evaluations on the same host (or container) as sensitive resources
  • Accept prompts or tool instructions from users or external systems without strict trust guarantees

In these environments, LLM outputs are executed using eval() under the assumption that the sandboxed locals dictionary is sufficient to constrain behavior.

Exploit preconditions

  • Attack surface: Application endpoints or workflows that send user-controlled or external text into Langroid agents configured with full_eval=True.
  • Required access: Ability to influence prompts, tool calls, or any text that reaches TableChatAgent.pandas_eval() or equivalent VectorStore evaluation paths.
  • Trigger point: Execution of Python's eval() / expression evaluation on LLM-generated content, with globals that still expose __builtins__.
  • Why exploitation is possible: The sandbox only clears locals, not the globals built-in namespace. Python automatically populates __builtins__, granting access to powerful primitives such as __import__, which can be chained to OS-level execution.

Why this happens

The defect stems from relying on Python's eval() with a partially constrained execution context, assuming that providing an empty locals dictionary yields a safe sandbox.

In reality, Python's evaluation model populates __builtins__ into the global namespace when not explicitly overridden, exposing functions like __import__ that can be used to access modules such as os and subprocess.

This behavior maps directly to CWE-94: Improper Control of Generation of Code ('Code Injection'), where dynamically generated or externally influenced code is executed without adequate restriction or validation.

The insecure pattern is: taking LLM-generated strings, passing them directly to eval() or similar dynamic execution functions, and assuming that simple namespace tweaks suffice to prevent access to powerful built-ins.

Potential impact

  • Attackers may execute arbitrary Python code on the host running the Langroid-based application.
  • Attackers could run OS commands (for example, via os.system or similar mechanisms), leading to full host compromise.
  • Attackers may exfiltrate secrets such as environment variables, API keys, database credentials, or configuration files.
  • Attackers can modify or delete application data, including databases and vector indices.
  • Attackers may pivot laterally to other systems reachable from the compromised host.

General mitigation guidance

Effective mitigation focuses on eliminating unsafe dynamic code execution and constraining what LLM outputs are allowed to do:

  • Avoid using eval(), exec(), or similar dynamic execution primitives on any LLM-generated or user-controlled content; prefer structured, declarative APIs or whitelisted operations.
  • If expression evaluation is necessary, use restricted evaluators or interpreters that provide a minimal, explicitly defined environment with no implicit built-ins.
  • Treat LLM outputs as untrusted input and subject them to strict validation, parsing, and allowlists before interpretation.
  • Design agent tool interfaces as parameterized functions where arguments are validated types and values, rather than free-form code fragments.
  • Run LLM tools and evaluation logic under least-privilege principles (e.g., non-root users, constrained containers, limited filesystem and network access) to reduce blast radius.
  • Separate sensitive system capabilities (file access, networking, process execution) into dedicated, tightly controlled services instead of exposing them directly to LLM-controlled code paths.

How teams detect issues like this

Detection can focus both on code-level patterns and runtime behaviors:

  • Use static analysis or linters to flag any use of eval(), exec(), or ast.literal_eval()-like APIs where input originates from LLM outputs, prompts, or user-controlled data.
  • Establish code review checklists that highlight dynamic execution, sandbox implementations, and any manual management of globals / locals as high-risk areas requiring security sign-off.
  • Enforce policies (for example, via automated pull request checks) that prohibit direct execution of model-generated strings; require mediation through safe interpreters or whitelisted actions.
  • Monitor application logs and telemetry for unusual tool messages, unexpected Python expression patterns, or OS command invocations initiated from LLM agent subsystems.
  • Instrument runtime environments (via EDR, audit logs, or container security tools) to detect anomalous process creation, file access, or network connections originating from Langroid agent processes.

Sources

SourceLink
github.comgithub.com/langroid/langroid/security/advisories/GHSA-q9p7-wqxg-mrhc

Frequently asked

questions

It is broadly exploitable in any deployment where untrusted parties can influence prompts, tool messages, or other text that reaches TableChatAgent or VectorStore evaluation with full_eval=True. In such setups, an attacker can often achieve full remote code execution without prior authentication.

Not necessarily. If the Langroid-based application exposes public endpoints or chat interfaces that feed into these agents, an unauthenticated user can supply malicious payloads via normal interaction channels. Private or internal deployments still face risk from insiders or compromised internal users.

The safest pattern is to remove all direct uses of eval(), exec(), and similar primitives on LLM outputs, replacing them with structured, whitelisted operations. Where expression evaluation is unavoidable, use a purpose-built restricted evaluator with an explicitly defined, minimal environment and no default access to __builtins__ or system interfaces.

Treat model outputs as untrusted data; never as code. Design tools as parameterized, typed functions with strict validation, isolate high-privilege capabilities into separate services, and incorporate security reviews specifically for dynamic execution and sandbox logic. Enforce development policies that prohibit direct execution of model-generated code and adopt automated checks to catch regressions early.

Find out what's already
exploitable in your codebase.