/

CVE-2026-25481

Severity:

CRITICAL RISK

(9.6)

Code Injection in Langroid TableChatAgent

CVE-2026-25481

Analyzed

Vulnerability type

Category:

Code Injection

CWE:

CWE-94

Impact:

Arbitrary Code Execution

Severity:

CRITICAL RISK

(9.6)

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

A code injection vulnerability in Langroid's TableChatAgent allows attackers to bypass the Web Application Firewall (WAF) in the pandas_eval tool and reach Python's eval builtin.

When an attacker can influence expressions evaluated by pandas_eval, they may chain allowed DataFrame methods with dangerous dunder attributes to execute arbitrary code within the application environment.

Affected context

This vulnerability affects Langroid-based applications that:

  • Use TableChatAgent or other components that expose the pandas_eval tool to user-controlled input
  • Rely on the WAF in langroid/utils/pandas_utils.py to filter unsafe expressions
  • Run in environments where the Python process has access to sensitive data, services, or the underlying OS

The risk is highest when end users can submit free-form analytical expressions that are passed directly into pandas_eval without additional server-side validation or sandboxing.

Exploit preconditions

  • Attack surface: Application interfaces (chat prompts, APIs, or UI fields) that accept table or DataFrame queries and route them into TableChatAgent's pandas_eval tool.
  • Required access: Ability to supply or influence the expression string evaluated by pandas_eval (typically unprivileged, remote user input).
  • Trigger point: Evaluation of the crafted expression inside pandas_eval, after it passes through _literal_ok() and the WAF logic.
  • Why exploitation is possible:
  • _literal_ok() returns False instead of raising UnsafeCommandError on invalid input, allowing processing to continue.
  • The WAF does not fully prevent access to dangerous dunder attributes (such as __init__, __globals__, __builtins__).
  • An attacker can chain whitelisted DataFrame methods with these attributes to reveal the eval builtin and execute arbitrary Python code.

Why this happens

The core issue aligns with CWE-94: Improper Control of Generation of Code ('Code Injection').

Langroid's pandas_eval feature is designed to interpret user-supplied expressions against pandas DataFrames. Instead of enforcing strict, safe evaluation semantics, the implementation:

  • Relies on a WAF-style filter (_literal_ok() and related checks) to distinguish safe from unsafe expressions.
  • Allows unrestricted access to powerful Python dunder attributes that can be used to escape the intended evaluation scope.
  • Treats expressions as sufficiently sanitized even when _literal_ok() returns False, because it does not raise an exception to halt processing.

This design combines dynamic expression evaluation with incomplete validation and strong reflection capabilities. As a result, user-controlled input can be transformed into executable Python code by navigating from DataFrame objects to interpreter internals and the eval builtin.

Potential impact

  • Execution of arbitrary Python code in the Langroid application process
  • Reading or modification of sensitive data accessible to the LLM application
  • Lateral movement to connected services (databases, APIs, message queues) using application credentials
  • File system access, including reading configuration files, secrets, or model artifacts
  • Denial of service by spawning expensive computations or processes
  • Use of the compromised application environment for further supply-chain or infrastructure attacks

General mitigation guidance

Effective mitigation focuses on eliminating unsafe code evaluation paths and constraining what expressions can do:

  • Replace generic eval-style mechanisms with strict, domain-specific expression interpreters that support only a fixed set of safe operations.
  • Treat all user-supplied expressions as untrusted, and avoid passing them directly to Python evaluation primitives or objects that can reach them.
  • Restrict or remove access to dangerous attributes and capabilities (e.g., __globals__, __builtins__, __dict__, module-level objects) from the evaluation context.
  • Apply positive allowlists of permitted DataFrame methods and expressions, and block all others by default.
  • Run code that processes user expressions in a sandboxed, least-privilege environment (separate process, container, or VM) with minimized OS and network permissions.
  • Log rejected expressions and suspicious evaluation attempts to support ongoing hardening and tuning of filters.

How teams detect issues like this

Detection can combine static review of code paths and runtime monitoring:

  • Static analysis and code review:
  • Search for any use of eval, exec, ast.literal_eval, or pandas evaluation helpers in code that can receive user input.
  • Flag flows where user-controlled strings reach pandas_eval or similar utilities without strict parsing or schema enforcement.
  • Review any WAF-style filters (_literal_ok(), pattern-based blockers) to ensure that failing validation halts execution rather than silently continuing.
  • Watch for access to powerful attributes such as __globals__, __builtins__, __dict__, and reflection APIs reachable from user expressions.
  • Policy and tooling:
  • Enforce secure-coding guidelines that discourage generic code evaluation and mandate allowlisted, declarative query languages.
  • Use SAST/IAST tools configured with rules for CWE-94 patterns and dataflow from user inputs to evaluation primitives.
  • Runtime monitoring:
  • Instrument logging around expression evaluation to record suspicious constructs or repeated failures.
  • Monitor for anomalous behavior originating from the application process (unexpected network calls, filesystem access, or subprocess creation).

Sources

SourceLink
github.comgithub.com/langroid/langroid/commit/30abbc1a854dee22fbd2f8b2f575dfdabdb603ea
github.comgithub.com/langroid/langroid/security/advisories/GHSA-jqq5-wc57-f8hj
github.comgithub.com/langroid/langroid/security/advisories/GHSA-x34r-63hx-w57f

Frequently asked

questions

Yes. If a Langroid-based application exposes TableChatAgent or pandas_eval to remote users, an attacker can exploit the issue simply by sending crafted expressions through the chat or API interface.

That depends on how the application is deployed. If table querying features are available to anonymous users, no authentication is needed. If these features are behind login or API keys, the attacker needs at least the same level of access as a normal user who can issue DataFrame-style queries.

The safest pattern is to remove generic code evaluation from the user input path. Replace eval-style behavior with a constrained expression engine or dedicated query language, enforce strict allowlists for operations, and ensure that any validation failure raises an error that aborts processing instead of falling through.

Avoid designs where user-controlled strings are directly interpreted as code or passed into powerful evaluation mechanisms. Use secure-by-default parsing libraries, implement positive allowlists and schemas, isolate analytic or computation features in low-privilege sandboxes, and add security-focused reviews and static analysis checks for CWE-94 patterns to your development lifecycle.

Find out what's already
exploitable in your codebase.