Code Injection in vm2-project
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.
There is a critical vulnerability in the vm2 library for Node.js. Without patching, attackers could use this library to take control of the server. This issue is fixed in version 3.11.0, and it is recommended to update immediately. This vulnerability could pose severe risks similar to past issues like Heartbleed.
A sandbox breakout vulnerability in vm2, a Node.js virtual machine library, allows attackers to execute code in the host environment. Affected versions are <=3.10.4, patched in 3.11.0. Exploitation involves using the __lookupGetter__ method with Buffer.apply to invoke the host apply method, enabling arbitrary code execution on the host. There is no workaround; updating to the latest version is necessary.
Sandbox breakout in vm2 allowing arbitrary code execution on the host system.
Within vm2 library running untrusted code.
Critical severity with CVSS 9.8, remote exploitation possible without user interaction.
Update to vm2 version 3.11.0 or later.
No known workarounds.
Monitor for unexpected file changes or command execution suggesting unauthorized access.
Related past incidentsSimilar incidents extracted from past CVEs
Similar vulnerability in Spring Framework allowing RCE via data binding.
Heartbleed vulnerability where memory leak allowed sensitive data exposure.
Log4Shell vulnerability in Apache Log4j allowing RCE via JNDI lookup.
If this happens at your companyExpected impact per business scenario
The attacked system could be fully compromised, allowing data theft and unauthorized access to resources.
Critical business processes could be disrupted, leading to loss of productivity and financial damage.
The provider's systems could be used to further launch attacks on client systems, damaging reputation and leading to compliance issues.
Company should immediately upgrade to vm2 version 3.11.0 and review systems for signs of past exploitation.
Response actions
Concrete steps and command examples for SOC/SRE teams to execute in order
-
1
Identify exposureidentify
grep -r 'vm2-project' . | grep -v node_modulesリポジトリと本番環境の依存ファイル (package-lock.json / requirements.txt / go.sum / Gemfile.lock 等) で
vm2-projectを grep し、稼働しているサービス・バージョンを把握する。 -
2
Match against affected rangeverify
Confirm if version satisfies `<= 3.10.4`Step 1 で見つかったバージョンが影響範囲
<= 3.10.4に該当するか照合。本番で稼働中ならインシデント扱い。 -
7
Post-deployment verificationverify
Confirm patched version is live in productionパッチ適用後、ステージングで PoC または同等の悪用パターンを再現して脆弱性が閉じたことを確認。本番では Step 3 と同じログクエリでアラート再発が無いか継続監視。
Affected packages
| Package | Affected → Fixed | |
|---|---|---|
| npmvm2 |
< 3.11.0→ 3.11.0 |
3.11.0 |
Original description The description as published by the source.
Summary
VM2 suffers from a sandbox breakout vulnerability. This allows attackers to write code which can escape from the VM2 sandbox and execute arbitrary commands on the host system.
Details
The __lookupGetter__ method allows to read the getter of an object. It is special in VM2 since it will switch between the host and sandbox version of the method when passed to the other context.
This allows to access getters on an object in the host context if the method is called from the host context which can be achieved by using the host apply method which can be accessed through Buffer.apply.
Afterwards, this function can be used to call the host version of __lookupGetter__ with Buffer and __proto__ resulting in the prototype lookup method from the host context.
With this method the hosts Function.prototype object can be retrieved and the host Function acquired through the constructor property which allows to create and run code in the host context.
This issue was attempted to be fixed with https://github.com/patriksimek/vm2/blob/4b009c2d4b1131c01810c1205e641d614c322a29/lib/bridge.js#L427. However, this can be circumvented by using Object.getOwnPropertyDescriptor to get the constructor property.
PoC
The following code demonstrates this issue by acquiring the host process object and executing touch pwned.
const {VM} = require("vm2");
const vm = new VM();
vm.run(`
const g = ({}).__lookupGetter__;
const a = Buffer.apply;
const p = a.apply…
Source: NIST National Vulnerability Database NVD GitHub Advisory
References
- advisory github.com
- advisory nvd.nist.gov
- package github.com
- web github.com
- web github.com
- web github.com
- web github.com
- web access.redhat.com
- web bugzilla.redhat.com
- web security.access.redhat.com
- web github.com