/

CVE-2026-29091

Severity:

HIGH RISK

(8.1)

Eval Injection / Code Injection in Locutus

CVE-2026-29091

Modified

Vulnerability type

Category:

Eval Injection / Code Injection

CWE:

CWE-95, CWE-94

Impact:

Remote Code Execution in JavaScript Runtime

Severity:

HIGH RISK

(8.1)

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

Locutus contains an eval injection vulnerability in its JavaScript implementation of call_user_func_array (and its wrapper call_user_func), where callback components are passed directly to eval() without sufficient validation.

When user-controlled values influence these callback arrays, an attacker can inject arbitrary JavaScript code into the runtime, leading to remote code execution in affected applications.

Affected context

This vulnerability appears in applications that use Locutus' PHP compatibility layer, specifically the JavaScript implementations of call_user_func_array or call_user_func.

It becomes relevant when:

  • Application logic accepts or builds callback arrays based on untrusted or partially trusted input (e.g., user parameters, query strings, serialized data, or configuration).
  • Those callback arrays transit through Locutus' call_user_func_array wrappers.
  • The environment executes Locutus code in a Node.js process, browser, or other JS runtime where eval has access to sensitive APIs or data.

In setups where callback values are strictly hard-coded and cannot be influenced by users, the practical risk is reduced but still warrants remediation since future changes may unintentionally expose the dangerous path.

Exploit preconditions

  • Attack surface: Any Locutus-using path that calls call_user_func_array / call_user_func with callback arrays.
  • Required access: Ability to influence or control any part of the callback array (e.g., function name, object reference, method name, or expression that is later serialized into the eval input).
  • Trigger point: Invocation of the vulnerable function with attacker-tainted callback data, causing Locutus to construct a string and pass it into eval().
  • Why exploitation is possible: The implementation does not robustly validate or constrain all parts of the callback array before building an eval string, violating CWE-95 by allowing untrusted input to reach eval() as executable JavaScript.

Why this happens

The core issue is the use of eval() on dynamically constructed code derived from callback arrays without rigorous validation or restriction.

Instead of treating callback arrays as data to be resolved using standard JavaScript function references, the implementation builds a string representation of the intended call and passes it to eval().

This pattern aligns with CWE-95: Improper Neutralization of Directives in Dynamically Evaluated Code: attacker-controlled input is insufficiently sanitized before being evaluated as code, enabling arbitrary script execution in the runtime.

Potential impact

  • Execution of arbitrary JavaScript code within the affected process.
  • Theft or modification of sensitive data accessible to the runtime (tokens, secrets, user data, configuration).
  • Abuse of the execution environment, such as:
  • For Node.js: filesystem access, process spawning, network calls, or environment inspection depending on available APIs and sandboxing.
  • For browser contexts: DOM manipulation, credential theft, or session hijacking within the same origin.
  • Lateral movement within the application's trust boundary by pivoting from the injected code to other internal services or components.
  • Service disruption, including crashes, resource exhaustion, or logic tampering.

General mitigation guidance

Effective mitigation focuses on removing or strictly controlling dynamic evaluation paths and enforcing clear separation between code and data:

  • Replace eval()-based dispatch with direct function references or method lookups:
  • Treat callbacks as actual function objects or pre-validated method names resolved via safe property access.
  • Constrain callback specification:
  • Only allow callbacks from a predefined, whitelisted set of functions or methods.
  • Reject or ignore any callback that does not match known-safe identifiers.
  • Apply strict validation on callback inputs:
  • Validate callback array structure (type, length, allowed characters in names).
  • Normalize and canonicalize input before use to avoid sneaky payloads.
  • Reduce privileges in the execution environment:
  • Run Node.js processes or browser code with the least necessary privileges and disable or limit dangerous APIs where possible.
  • Adopt secure-by-default library usage patterns:
  • Prefer APIs that do not rely on string-based code evaluation.
  • Document and discourage patterns that construct callbacks from raw user input.

How teams detect issues like this

Organizations can detect and manage this class of vulnerability using multiple complementary techniques:

  • Static analysis and linting:
  • Flag occurrences of eval, Function constructors, and similar dynamic code execution APIs in Locutus usage or surrounding glue code.
  • Add rules that specifically highlight dynamic construction of strings passed into these functions.
  • Code review practices:
  • During review, scrutinize any use of call_user_func_array / call_user_func and verify that callbacks are not derived from user-controlled sources.
  • Look for patterns where user input is concatenated into function names, object paths, or expressions.
  • Policy and CI enforcement:
  • Enforce coding standards that disallow or tightly control eval() and related mechanisms, with automated checks in CI.
  • Integrate SAST tools that understand JavaScript data flow and can trace tainted input to dynamic evaluation sinks.
  • Runtime monitoring:
  • In high-value environments, monitor for unusual dynamic code execution patterns, unexpected errors from eval calls, or anomalous behavior after routes invoking Locutus callbacks.

Sources

SourceLink
github.comgithub.com/locutusjs/locutus/commit/977a1fb169441e35996a1d2465b512322de500ad
github.comgithub.com/locutusjs/locutus/security/advisories/GHSA-fp25-p6mj-qqg6
access.redhat.comaccess.redhat.com/security/cve/CVE-2026-29091
bugzilla.redhat.combugzilla.redhat.com/show_bug.cgi?id=2445262
security.access.redhat.comsecurity.access.redhat.com/data/csaf/v2/vex/2026/cve-2026-29091.json

Frequently asked

questions

Exploitability depends on whether an attacker can influence the callback arrays passed into Locutus' call_user_func_array or call_user_func. If callbacks are constructed directly or indirectly from user input (including request parameters, serialized structures, or configuration they can modify), the issue can often be exploited to run arbitrary JavaScript. If callbacks are entirely static and never derived from untrusted data, practical risk is lower but still warrants fixing due to future code changes.

An attacker typically needs the ability to submit or manipulate data that flows into the callback array parameters. This might be through a web form, API endpoint, query parameter, or other input surface that your application uses when calling these Locutus functions. They do not need direct access to the server or codebase—just control over the data that reaches the vulnerable eval path.

The safest pattern is to eliminate dynamic evaluation entirely: do not use eval() or similar constructs for function dispatch. Instead, operate on real function references, or resolve method names via controlled lookups into a whitelist of allowed call targets. Ensure callback arrays are strongly validated for type and content, rejecting anything outside expected structures.

Prevention involves a combination of coding discipline and tooling: avoid eval() and dynamic code generation wherever possible; design APIs that use explicit function references rather than string-based identifiers; validate and sanitize any input that influences control flow; and include static analysis, lint rules, and code review checklists that specifically flag dynamic evaluation and callback construction from untrusted data.

Find out what's already
exploitable in your codebase.