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.
String literal content in cg.parse() is injected verbatim into new Function() body without sanitization, leading to RCE.
In the math-codegen library, within the cg.parse() function.
Critical, allowing full remote code execution without prior authentication or user interaction.
Upgrade to math-codegen version 0.4.3 or later.
Manually escape user inputs or use JSON.stringify() before passing inputs to cg.parse().
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
攻撃者がサーバーに悪意のあるコードを実行し、顧客データにアクセスする可能性があります。
不正な取引や顧客のプライバシー侵害が発生する可能性があります。
開発者の作業環境が不正に操作され、機密コードが盗まれる恐れがあります。
適切なパッチを適用しユーザー入力の削除処理を強化してください。
Response actions
Concrete steps and command examples for SOC/SRE teams to execute in order
-
1
Identify exposureidentify
Audit SBOM/dependencies for affected components.依存マニフェストで影響コンポーネントを特定する。
-
2
Match against affected rangeverify
Confirm if version satisfies `< 0.4.3`Step 1 で見つかったバージョンが影響範囲
< 0.4.3に該当するか照合。本番で稼働中ならインシデント扱い。 -
7
Post-deployment verificationverify
Confirm patched version is live in productionパッチ適用後、ステージングで PoC または同等の悪用パターンを再現して脆弱性が閉じたことを確認。本番では Step 3 と同じログクエリでアラート再発が無いか継続監視。
Affected packages
| Package | Affected → Fixed | |
|---|---|---|
| npmmath-codegen |
< 0.4.3→ 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
- advisory nvd.nist.gov
- advisory github.com
- issue security-advisories@github.com
- package github.com
- patch security-advisories@github.com
- patch security-advisories@github.com
- web github.com
- web github.com