CVE-2026-41507
JSON

9.8critical

Remote Code Execution (RCE) via String Literal Injection into math-codegen

Severity
9.8critical CVSS:3.1 by GitHub_M
Exploit likelihood
0.67% (higher than 47% of CVEs)
Published
Last changed
Assigned by
GitHub_M
Also known as
GHSA-p6x5-p4xf-cc4r

Description

math-codegen generates code from mathematical expressions. Prior to version 0.4.3, string literal content passed to cg.parse() is injected verbatim into a new Function() body without sanitization. This allows an attacker to execute arbitrary system commands when user-controlled input reaches the parser. Any application exposing a math evaluation endpoint where user input flows into cg.parse() is vulnerable to full RCE. This issue has been patched in version 0.4.3.

Affected

Product or packageVersionsReported by
mauriciopoppe math-codegen< 0.4.3, before 0.4.3CVE List, NVD
math-codegen (npm)before 0.4.3GitHub Advisory Database

All scores

GitHub_M9.8critical CVSS:3.1CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H
GitHub9.8critical CVSS:3.1CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H

Classification

CWE-94

SSVC (CISA-ADP): exploitation none, automatable yes, technical impact total.

What each source says

CVE List

math-codegen generates code from mathematical expressions. Prior to version 0.4.3, string literal content passed to cg.parse() is injected verbatim into a new Function() body without sanitization. This allows an attacker to execute arbitrary system commands when user-controlled input reaches the parser. Any application exposing a math evaluation endpoint where user input flows into cg.parse() is vulnerable to full RCE. This issue has been patched in version 0.4.3.

GitHub Advisory Database
Impact

String literal content passed to cg.parse() is injected verbatim into a new Function() body without sanitization. This allows an attacker to execute arbitrary system commands when user-controlled input reaches the parser. Any application exposing a math evaluation endpoint where user input flows into cg.parse() is vulnerable to full RCE.

Patches

The vulnerability is addressed by using JSON.stringify() on string literal values in lib/node/ConstantNode.js to ensure they are treated as data rather than code. Users should upgrade to version 0.4.3 or later.

Workarounds

Avoid passing un-sanitized user input to the parser or manually escape string literals in the input.

NVD (es)

math-codegen genera código a partir de expresiones matemáticas. Antes de la versión 0.4.3, el contenido de cadena literal pasado a cg.parse() se inyecta textualmente en el cuerpo de una nueva Function() sin sanitización. Esto permite a un atacante ejecutar comandos de sistema arbitrarios cuando la entrada controlada por el usuario llega al analizador. Cualquier aplicación que exponga un punto final de evaluación matemática donde la entrada del usuario fluye hacia cg.parse() es vulnerable a RCE completo. Este problema ha sido parcheado en la versión 0.4.3.

References

Sources

SourceRecordLicence
CVE ListCVE-2026-41507 changed 2026-05-08CVE Terms of Use
GitHub Advisory DatabaseGHSA-p6x5-p4xf-cc4r changed 2026-05-12CC-BY-4.0
NVDCVE-2026-41507 changed 2026-10-26Public domain