The SentinelOne Annual Threat Report - A Defenders Guide from the FrontlinesThe SentinelOne Annual Threat ReportGet the Report
Experiencing a Breach?Blog
Get StartedContact Us
SentinelOne
  • Platform
    Platform Overview
    • Singularity Platform
      Welcome to Integrated Enterprise Security
    • AI for Security
      Leading the Way in AI-Powered Security Solutions
    • Securing AI
      Accelerate AI Adoption with Secure AI Tools, Apps, and Agents.
    • How It Works
      The Singularity XDR Difference
    • Singularity Marketplace
      One-Click Integrations to Unlock the Power of XDR
    • Pricing & Packaging
      Comparisons and Guidance at a Glance
    Data & AI
    • Purple AI
      Accelerate SecOps with Generative AI
    • Singularity Hyperautomation
      Easily Automate Security Processes
    • AI-SIEM
      The AI SIEM for the Autonomous SOC
    • AI Data Pipelines
      Security Data Pipeline for AI SIEM and Data Optimization
    • Singularity Data Lake
      AI-Powered, Unified Data Lake
    • Singularity Data Lake for Log Analytics
      Seamlessly Ingest Data from On-Prem, Cloud or Hybrid Environments
    Endpoint Security
    • Singularity Endpoint
      Autonomous Prevention, Detection, and Response
    • Singularity XDR
      Native & Open Protection, Detection, and Response
    • Singularity RemoteOps Forensics
      Orchestrate Forensics at Scale
    • Singularity Threat Intelligence
      Comprehensive Adversary Intelligence
    • Singularity Vulnerability Management
      Application & OS Vulnerability Management
    • Singularity Identity
      Identity Threat Detection and Response
    Cloud Security
    • Singularity Cloud Security
      Block Attacks with an AI-Powered CNAPP
    • Singularity Cloud Native Security
      Secure Cloud and Development Resources
    • Singularity Cloud Workload Security
      Real-Time Cloud Workload Protection Platform
    • Singularity Cloud Data Security
      AI-Powered Threat Detection for Cloud Storage
    • Singularity Cloud Security Posture Management
      Detect and Remediate Cloud Misconfigurations
    Securing AI
    • Prompt Security
      Secure AI Tools Across Your Enterprise
  • Why SentinelOne?
    Why SentinelOne?
    • Why SentinelOne?
      Cybersecurity Built for What’s Next
    • Our Customers
      Trusted by the World’s Leading Enterprises
    • Industry Recognition
      Tested and Proven by the Experts
    • About Us
      The Industry Leader in Autonomous Cybersecurity
    Compare SentinelOne
    • Arctic Wolf
    • Broadcom
    • CrowdStrike
    • Cybereason
    • Microsoft
    • Palo Alto Networks
    • Sophos
    • Splunk
    • Trellix
    • Trend Micro
    • Wiz
    Verticals
    • Energy
    • Federal Government
    • Finance
    • Healthcare
    • Higher Education
    • K-12 Education
    • Manufacturing
    • Retail
    • State and Local Government
  • Services
    Managed Services
    • Managed Services Overview
      Wayfinder Threat Detection & Response
    • Threat Hunting
      World-Class Expertise and Threat Intelligence
    • Managed Detection & Response
      24/7/365 Expert MDR Across Your Entire Environment
    • Incident Readiness & Response
      DFIR, Breach Readiness, & Compromise Assessments
    Support, Deployment, & Health
    • Technical Account Management
      Customer Success with Personalized Service
    • SentinelOne GO
      Guided Onboarding & Deployment Advisory
    • SentinelOne University
      Live and On-Demand Training
    • Services Overview
      Comprehensive Solutions for Seamless Security Operations
    • SentinelOne Community
      Community Login
  • Partners
    Our Network
    • MSSP Partners
      Succeed Faster with SentinelOne
    • Singularity Marketplace
      Extend the Power of S1 Technology
    • Cyber Risk Partners
      Enlist Pro Response and Advisory Teams
    • Technology Alliances
      Integrated, Enterprise-Scale Solutions
    • SentinelOne for AWS
      Hosted in AWS Regions Around the World
    • Channel Partners
      Deliver the Right Solutions, Together
    • SentinelOne for Google Cloud
      Unified, Autonomous Security Giving Defenders the Advantage at Global Scale
    • Partner Locator
      Your Go-to Source for Our Top Partners in Your Region
    Partner Portal→
  • Resources
    Resource Center
    • Case Studies
    • Data Sheets
    • eBooks
    • Reports
    • Videos
    • Webinars
    • Whitepapers
    • Events
    View All Resources→
    Blog
    • Feature Spotlight
    • For CISO/CIO
    • From the Front Lines
    • Identity
    • Cloud
    • macOS
    • SentinelOne Blog
    Blog→
    Tech Resources
    • SentinelLABS
    • Ransomware Anthology
    • Cybersecurity 101
  • About
    About SentinelOne
    • About SentinelOne
      The Industry Leader in Cybersecurity
    • Investor Relations
      Financial Information & Events
    • SentinelLABS
      Threat Research for the Modern Threat Hunter
    • Careers
      The Latest Job Opportunities
    • Press & News
      Company Announcements
    • Cybersecurity Blog
      The Latest Cybersecurity Threats, News, & More
    • FAQ
      Get Answers to Our Most Frequently Asked Questions
    • DataSet
      The Live Data Platform
    • S Foundation
      Securing a Safer Future for All
    • S Ventures
      Investing in the Next Generation of Security, Data and AI
  • Pricing
Get StartedContact Us
CVE Vulnerability Database
Vulnerability Database/CVE-2026-41507

CVE-2026-41507: Mauriciopoppe Math-codegen RCE Flaw

CVE-2026-41507 is a remote code execution vulnerability in Mauriciopoppe Math-codegen that allows attackers to execute arbitrary commands through unsanitized input. This article covers the technical details, affected versions, and mitigation.

Published: May 18, 2026

CVE-2026-41507 Overview

CVE-2026-41507 is a code injection vulnerability in math-codegen, a Node.js library by Mauriciopoppe that generates JavaScript code from mathematical expressions. Versions prior to 0.4.3 inject string literal content from cg.parse() directly into a new Function() body without sanitization. Any application that forwards user-controlled input to the parser is exposed to remote code execution (RCE). The maintainer addressed the issue in version 0.4.3 by serializing inputs with JSON.stringify() and validating the factory option against a strict identifier pattern. The flaw is tracked under CWE-94: Improper Control of Generation of Code.

Critical Impact

Unauthenticated attackers reaching a vulnerable math evaluation endpoint can execute arbitrary system commands in the Node.js process context.

Affected Products

  • mauriciopoppe/math-codegen versions prior to 0.4.3
  • Node.js applications exposing cg.parse() to user-controlled input
  • Web services using math-codegen for expression evaluation endpoints

Discovery Timeline

  • 2026-05-08 - CVE-2026-41507 published to NVD
  • 2026-05-12 - Last updated in NVD database

Technical Details for CVE-2026-41507

Vulnerability Analysis

The math-codegen library converts mathematical expressions into executable JavaScript by constructing a function body and instantiating it via new Function(). The code generator embeds the user-supplied expression string into the generated source using naive string concatenation. String literals such as "foo" are placed verbatim between single quotes in the output, so an input containing a closing quote followed by JavaScript statements terminates the literal and injects attacker-controlled code into the function body.

When the generated function executes, the injected payload runs with the privileges of the Node.js process. An attacker can invoke require('child_process').execSync() or similar APIs to execute arbitrary shell commands, read sensitive files, or pivot inside the host environment.

Root Cause

The defect originates in lib/CodeGenerator.js, which built the generated module using the expression " code: '" + code + "'". This produces unsafe source whenever code contains a single quote or newline. A secondary issue in lib/Interpreter.js accepted an arbitrary factory option that flowed into generated code without validation, providing another injection sink.

Attack Vector

Exploitation requires only that user input reach cg.parse(). The attacker submits an expression string crafted to break out of the embedded literal and append JavaScript statements. No authentication, user interaction, or local access is required when the endpoint is exposed over the network.

javascript
// Security patch in lib/CodeGenerator.js (commit 4bb52d3)
     '    $$processScope(scope)',
     '    ' + code,
     '  },',
-    "  code: '" + code + "'",
+    '  code: ' + JSON.stringify(code),
     '}'
   ].join('\n')

Source: GitHub Commit 4bb52d3

The fix replaces unsafe concatenation with JSON.stringify(), which produces a properly escaped JavaScript string literal regardless of input content.

javascript
// Security patch in lib/Interpreter.js (commit 4bb52d3)
   const factory = this.options.factory
   if (typeof factory !== 'string' || !/^[a-zA-Z_$][a-zA-Z0-9_$]*(\.[a-zA-Z_$][a-zA-Z0-9_$]*)*$/.test(factory)) {
     throw new Error('factory must be a valid JS property access path (e.g. "ns.factory")')
   }

Source: GitHub Commit 4bb52d3

The patch additionally enforces that the factory option matches a valid JavaScript property access path, blocking injection through that vector.

Detection Methods for CVE-2026-41507

Indicators of Compromise

  • Unexpected child processes (sh, bash, cmd.exe, powershell.exe) spawned by the Node.js application
  • Outbound network connections from the Node.js process to attacker infrastructure following math expression submissions
  • HTTP request bodies containing single quotes, backslashes, or JavaScript keywords (require, process, function) in fields that feed math evaluation endpoints

Detection Strategies

  • Inventory dependencies with npm ls math-codegen and flag any version below 0.4.3
  • Use software composition analysis (SCA) tooling to identify direct and transitive uses of mauriciopoppe/math-codegen
  • Add WAF rules that reject expression inputs containing quote characters, semicolons, or known RCE primitives

Monitoring Recommendations

  • Audit application logs for parse errors or anomalous expression payloads sent to math endpoints
  • Monitor process trees for the Node.js runtime spawning unexpected interpreters or system binaries
  • Alert on Node.js processes initiating outbound connections to unfamiliar IPs or domains

How to Mitigate CVE-2026-41507

Immediate Actions Required

  • Upgrade math-codegen to version 0.4.3 or later across all affected services
  • Review application code for any path where untrusted input reaches cg.parse() and add server-side validation
  • Restrict the runtime privileges of the Node.js process so a successful RCE has limited blast radius

Patch Information

The maintainer released the fix in commit 4bb52d3 shipped as version 0.4.3. Full advisory details are available in the GitHub Security Advisory GHSA-p6x5-p4xf-cc4r and Pull Request #11.

Workarounds

  • Validate user-supplied expressions against a strict allowlist of mathematical characters before invoking cg.parse()
  • Wrap math evaluation in an isolated worker with the vm2 sandbox or a separate process with seccomp restrictions
  • Disable or remove any HTTP endpoint that exposes cg.parse() to unauthenticated callers until patching completes
bash
# Upgrade math-codegen to the patched release
npm install math-codegen@^0.4.3

# Verify the installed version
npm ls math-codegen

# Audit the dependency tree for vulnerable advisories
npm audit --production

Disclaimer: This content was generated using AI. While we strive for accuracy, please verify critical information with official sources.

  • Vulnerability Details
  • TypeRCE

  • Vendor/TechMauriciopoppe Math Codegen

  • SeverityCRITICAL

  • CVSS Score9.8

  • EPSS Probability0.06%

  • Known ExploitedNo
  • CVSS Vector
  • CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H
  • Impact Assessment
  • ConfidentialityLow
  • IntegrityNone
  • AvailabilityHigh
  • CWE References
  • CWE-94
  • Technical References
  • GitHub Pull Request #11
  • Vendor Resources
  • GitHub Commit Details

  • GitHub Security Advisory GHSA-p6x5-p4xf-cc4r
  • Latest CVEs
  • CVE-2026-46333: Linux Kernel Privilege Escalation Flaw

  • CVE-2026-2586: Eclipse Glassfish RCE Vulnerability

  • CVE-2026-2587: Eclipse Glassfish RCE Vulnerability

  • CVE-2026-45255: FreeBSD bsdinstall/bsdconfig RCE Flaw
Default Legacy - Prefooter | Experience the World’s Most Advanced Cybersecurity Platform

Experience the Most Advanced Cybersecurity Platform

See how the world’s most intelligent, autonomous cybersecurity platform can protect your organization today and into the future.

Try SentinelOne
  • Get Started
  • Get a Demo
  • Product Tour
  • Why SentinelOne
  • Pricing & Packaging
  • FAQ
  • Contact
  • Contact Us
  • Customer Support
  • SentinelOne Status
  • Language
  • Platform
  • Singularity Platform
  • Singularity Endpoint
  • Singularity Cloud
  • Singularity AI-SIEM
  • Singularity Identity
  • Singularity Marketplace
  • Purple AI
  • Services
  • Wayfinder TDR
  • SentinelOne GO
  • Technical Account Management
  • Support Services
  • Verticals
  • Energy
  • Federal Government
  • Finance
  • Healthcare
  • Higher Education
  • K-12 Education
  • Manufacturing
  • Retail
  • State and Local Government
  • Cybersecurity for SMB
  • Resources
  • Blog
  • Labs
  • Case Studies
  • Videos
  • Product Tours
  • Events
  • Cybersecurity 101
  • eBooks
  • Webinars
  • Whitepapers
  • Press
  • News
  • Ransomware Anthology
  • Company
  • About Us
  • Our Customers
  • Careers
  • Partners
  • Legal & Compliance
  • Security & Compliance
  • Investor Relations
  • S Foundation
  • S Ventures

©2026 SentinelOne, All Rights Reserved.

Privacy Notice Terms of Use

English