Skip to content
Critical 9.8 Developer Tooling Other

Code Injection in remote

CVE-2026-41507 First seen on SecPulse

AI summary

Produced by SecPulse using an external AI model; it may contain mistakes. Check the original description and references below before acting on it.

A critical issue has been found in certain versions of the math-codegen software, where user input can be exploited to execute arbitrary system commands. This could lead to the system being taken over by an attacker. Affected versions are those below 0.4.3, with a fix available in version 0.4.3. Immediate update is recommended.

The vulnerability arises in the cg.parse() method where user input is improperly sanitized, being directly injected into the body of a new Function(), allowing arbitrary code execution. The patch is available in version 0.4.3, affecting versions earlier than this. As a workaround, manually escape user inputs or utilize JSON.stringify() before processing. This vulnerability was reported by GitHub user hits3134.

What is the problem

String literal content in cg.parse() is injected verbatim into new Function() body without sanitization, leading to RCE.

Affected scope

In the math-codegen library, within the cg.parse() function.

Severity

Critical, allowing full remote code execution without prior authentication or user interaction.

How to fix

Upgrade to math-codegen version 0.4.3 or later.

Workaround

Manually escape user inputs or use JSON.stringify() before passing inputs to cg.parse().

Detection

Check for instances where cg.parse() is called with user-provided inputs in versions before 0.4.3.

Related past incidentsSimilar incidents extracted from past CVEs

Similar RCE vulnerability due to unsanitized user input in a JavaScript library.

Another instance of RCE vulnerability through improper input sanitization in a code generation library.

Both vulnerabilities allow unintended code/data access but differ in technique.

If this happens at your companyExpected impact per business scenario

ECサイトの場合

攻撃者がサーバーに悪意のあるコードを実行し、顧客データにアクセスする可能性があります。

金融機関のアプリケーション

不正な取引や顧客のプライバシー侵害が発生する可能性があります。

社内開発環境

開発者の作業環境が不正に操作され、機密コードが盗まれる恐れがあります。

Recommended action

適切なパッチを適用しユーザー入力の削除処理を強化してください。

Response actions

Concrete steps and command examples for SOC/SRE teams to execute in order

  1. 1
    Identify exposureidentify
    Audit SBOM/dependencies for affected components.

    依存マニフェストで影響コンポーネントを特定する。

  2. 2
    Match against affected rangeverify
    Confirm if version satisfies `< 0.4.3`

    Step 1 で見つかったバージョンが影響範囲 < 0.4.3 に該当するか照合。本番で稼働中ならインシデント扱い。

  3. 7
    Post-deployment verificationverify
    Confirm patched version is live in production

    パッチ適用後、ステージングで PoC または同等の悪用パターンを再現して脆弱性が閉じたことを確認。本番では Step 3 と同じログクエリでアラート再発が無いか継続監視。

Affected packages

PackageAffected → Fixed
npmmath-codegen
< 0.4.3→ 0.4.3
Original description The description as published by the source.

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.

Source: NIST National Vulnerability Database NVD GitHub Advisory

References

We use cookies for analytics and ad measurement. This setting applies to all Game co., Ltd. sites. Details