Vulnerabilities in pkg:npm/math-codegen
PACKAGECVE-2026-41507 is a CRITICAL (CVSS 9.8) remote code execution vulnerability (CWE-94: Improper Control of Generation of Code ('Code Injection')) affecting Math codegen libraries in the npm ecosystem. The issue involves remote code execution (rce) via string literal injection into math-codegen. Remediation is available by upgrading affected packages to version 0.4.3.
pkg:npm/math-codegen
Vulnerability advisories affecting package pkg:npm/math-codegen. Select an advisory below to view technical details or fixes.
| Advisory ID | CVE / NVD | Severity | Summary |
|---|---|---|---|
| GHSA-p6x5-p4xf-cc4r | CVE-2026-41507 | CRITICAL | Remote Code Execution (RCE) via String Literal Injection into math-codegen |
CVE-2026-41507 at a Glance
Security Impact
CVSS: 9.8
The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H).
How to Fix CVE-2026-41507
To remediate this vulnerability, upgrade all affected Math codegen dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.
npm install math-codegen@0.4.3
Run the following command in your project directory to verify that all resolved dependencies use the patched release:
npm ls math-codegen
How to Check if You Are Affected
To determine whether your Node.js application is affected by CVE-2026-41507, inspect your project dependencies using npm:
npm ls math-codegen
Analyze the terminal output to locate any version of Math codegen in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 0.4.3), your application is affected.
Note: The npm ls math-codegen command inspects dependencies declared in your package.json and lockfile; it does not perform automated runtime dynamic scanning.
Technical Details
Vulnerability Mechanism & Technical Analysis
This vulnerability is classified under CWE-94: Improper Control of Generation of Code ('Code Injection'), where 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. In Math codegen, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.
Source Advisory Statement
CVE-2026-41507 Affected Math codegen Versions
1 component(s)| Product / Package | Ecosystem | Affected Versions | Fixed Version |
|---|---|---|---|
|
math-codegen
|
npm |
< 0.4.3
|
0.4.3
|
References
Frequently Asked Questions
What is CVE-2026-41507?
Which Math codegen versions are affected?
What version fixes CVE-2026-41507?
Is math-codegen affected?
What is the CVSS score of CVE-2026-41507?
What CWE is associated with CVE-2026-41507?
How can I check npm dependencies for CVE-2026-41507?
Machine-readable OSV JSON
OSV v1.5 Schema
{
"schema_version" : "1.4.0",
"id" : "GHSA-p6x5-p4xf-cc4r",
"modified" : "2026-05-12T13:32:44Z",
"published" : "2026-04-17T22:31:45Z",
"aliases" : [ "CVE-2026-41507" ],
"summary" : "Remote Code Execution (RCE) via String Literal Injection into math-codegen",
"details" : "### Impact\n\nString 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.\n \n### Patches\n\nThe 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.\n \n### Workarounds\n\nAvoid passing un-sanitized user input to the parser or manually escape string literals in the input.",
"severity" : [ {
"type" : "CVSS_V3",
"score" : "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H"
} ],
"affected" : [ {
"package" : {
"ecosystem" : "npm",
"name" : "math-codegen"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "0"
}, {
"fixed" : "0.4.3"
} ]
} ]
} ],
"references" : [ {
"type" : "WEB",
"url" : "https://github.com/mauriciopoppe/math-codegen/security/advisories/GHSA-p6x5-p4xf-cc4r"
}, {
"type" : "ADVISORY",
"url" : "https://nvd.nist.gov/vuln/detail/CVE-2026-41507"
}, {
"type" : "WEB",
"url" : "https://github.com/mauriciopoppe/math-codegen/pull/11"
}, {
"type" : "WEB",
"url" : "https://github.com/mauriciopoppe/math-codegen/commit/4bb52d3030683362b3559ee8dd91350555a05f6b"
}, {
"type" : "WEB",
"url" : "https://github.com/hits3134"
}, {
"type" : "PACKAGE",
"url" : "https://github.com/mauriciopoppe/math-codegen"
} ],
"database_specific" : {
"cwe_ids" : [ "CWE-94" ],
"severity" : "CRITICAL",
"github_reviewed" : true,
"github_reviewed_at" : "2026-04-17T22:31:45Z",
"nvd_published_at" : "2026-05-08T14:16:34Z"
}
}