🇰🇷 한글 설명
vm2 샌드박스에서 require 옵션에 배열을 전달할 경우 타입 검사 로직의 허점으로 인해 호스트 모듈에 접근할 수 있는 취약점입니다. 공격자는 이를 통해 내부적으로 권한이 강화된 새로운 NodeVM을 생성하여 호스트 프로세스의 권한으로 임의의 명령을 실행할 수 있습니다.
💡 쉬운 설명
안전하게 코드를 실행해주는 가상 공간(샌드박스)의 보안 벽에 구멍이 생긴 상태입니다. 공격자가 특수한 설정을 입력하면 가상 공간을 탈출하여 실제 컴퓨터를 마음대로 조종할 수 있습니다.
🇺🇸 원문 (English)
vm2 is a sandbox for running untrusted Node.js code. In versions >= 3.11.4 and <= 3.11.6, the NodeVM constructor computes `hasRealRequireConfig` with `typeof requireOpts === 'object' && requireOpts !== null`, so an array-shaped `require` value (for example `require: []`) satisfies the guard that is meant to reject nesting without an explicit require configuration. `makeResolverFromLegacyOptions()` then destructures the array into undefined option fields and returns a resolver containing only `NESTING_OVERRIDE.vm2`. As a result, an attacker who can supply JavaScript executed by a NodeVM configured with truthy `nesting` and an array-shaped `require` (e.g. `new NodeVM({nesting: true, require: []})`) can require the host `vm2` module, create an inner NodeVM with an attacker-chosen builtin allowlist (such as `child_process`), and execute arbitrary commands with the privileges of the host Node.js process, escaping the sandbox. Outer builtin restrictions do not constrain the attacker-created inner NodeVM. This issue is fixed in vm2 3.11.7.
📍 영향받는 시스템
vm2 versions >= 3.11.4 and <= 3.11.6
⚔️ 공격 벡터
NodeVM 생성 시 nesting 옵션을 true로 설정하고 require 옵션에 배열([])을 전달하여 호스트 모듈을 호출
🛡️ 대응 방법
vm2 버전을 3.11.7 이상으로 업데이트
🔧 검증 코드
출력된 vm2의 버전이 3.11.7 미만(3.11.4~3.11.6 사이)인지 확인