Skip to content

Locutus vulnerable to RCE via unsanitized input in create_function()

Critical severity GitHub Reviewed Published Mar 12, 2026 in locutusjs/locutus • Updated Mar 16, 2026

Package

npm locutus (npm)

Affected versions

<= 3.0.13

Patched versions

3.0.14

Description

Summary

The create_function(args, code) function passes both parameters directly to the Function constructor without any sanitization, allowing arbitrary code execution.

This is distinct from CVE-2026-29091 (GHSA-fp25-p6mj-qqg6) which was call_user_func_array using eval() in v2.x. This finding affects create_function using new Function() in v3.x.

Root Cause

src/php/funchand/create_function.ts:17:

return new Function(...params, code)

Zero input validation on either parameter.

PoC

const { create_function } = require('locutus/php/funchand/create_function');
const rce = create_function('', 'return require("child_process").execSync("id").toString()');
console.log(rce());
// Output: uid=501(user) gid=20(staff) ...

Confirmed on locutus v3.0.11, Node.js v24.13.1.

Impact

Full RCE when an attacker can control either argument to create_function(). 597K weekly npm downloads.

Suggested Fix

Remove create_function or replace new Function() with a safe alternative. PHP itself deprecated create_function() in PHP 7.2 for the same reason.

Response

Thanks for the report.

We confirmed that php/funchand/create_function was still present through locutus@3.0.13 and that it exposed dynamic code execution via new Function(...).

While this was intended behavior, create_function() inherently needs to be unsafe in order for it to work, create_function() was deprecated in PHP 7.2 and removed in PHP 8.0. Given that Locutus' parity target today is 8.3, this function shouldn't have been in Locutus at all anymore.

We fixed this in locutus@3.0.14 by removing php/funchand/create_function entirely. That matches our PHP 8.3 parity target more closely: .

We also updated php/var/var_export so closures now export using the PHP 8-style \Closure::__set_state(array(...)) form instead of referencing the removed API.

Release:

Credit to @ByamB4 for the report.

References

@kvz kvz published to locutusjs/locutus Mar 12, 2026
Published to the GitHub Advisory Database Mar 13, 2026
Reviewed Mar 13, 2026
Published by the National Vulnerability Database Mar 13, 2026
Last updated Mar 16, 2026

Severity

Critical

CVSS overall score

This score calculates overall vulnerability severity from 0 to 10 and is based on the Common Vulnerability Scoring System (CVSS).
/ 10

CVSS v3 base metrics

Attack vector
Network
Attack complexity
Low
Privileges required
None
User interaction
None
Scope
Unchanged
Confidentiality
High
Integrity
High
Availability
High

CVSS v3 base metrics

Attack vector: More severe the more the remote (logically and physically) an attacker can be in order to exploit the vulnerability.
Attack complexity: More severe for the least complex attacks.
Privileges required: More severe if no privileges are required.
User interaction: More severe when no user interaction is required.
Scope: More severe when a scope change occurs, e.g. one vulnerable component impacts resources in components beyond its security scope.
Confidentiality: More severe when loss of data confidentiality is highest, measuring the level of data access available to an unauthorized user.
Integrity: More severe when loss of data integrity is the highest, measuring the consequence of data modification possible by an unauthorized user.
Availability: More severe when the loss of impacted component availability is highest.
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H

EPSS score

Exploit Prediction Scoring System (EPSS)

This score estimates the probability of this vulnerability being exploited within the next 30 days. Data provided by FIRST.
(28th percentile)

Weaknesses

Improper Control of Generation of Code ('Code Injection')

The product constructs all or part of a code segment using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the syntax or behavior of the intended code segment. Learn more on MITRE.

CVE ID

CVE-2026-32304

GHSA ID

GHSA-vh9h-29pq-r5m8

Source code

Credits

Loading Checking history
See something to contribute? Suggest improvements for this vulnerability.