Remote Code Execution (RCE) via String Literal Injection into math-codegen
Critical severity
GitHub Reviewed
Published
Apr 16, 2026
in
mauriciopoppe/math-codegen
•
Updated Apr 17, 2026
Description
Published to the GitHub Advisory Database
Apr 17, 2026
Reviewed
Apr 17, 2026
Last updated
Apr 17, 2026
Impact
String literal content passed to
cg.parse()is injected verbatim into anew 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 intocg.parse()is vulnerable to full RCE.Patches
The vulnerability is addressed by using
JSON.stringify()on string literal values inlib/node/ConstantNode.jsto 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.
References