🇰🇷 한글 설명
Wasmtime 런타임에서 externref를 사용하는 Wasm 실행 중 epoch interruption 기능이 활성화되어 있을 때 발생하는 Use-After-Free 취약점입니다. Cranelift 컴파일러가 콜드 블록 내의 세이프포인트에 대해 스택 맵을 생성하지 못해 가비지 컬렉션 과정에서 활성 참조를 잘못 해제하면서 발생합니다.
💡 쉬운 설명
프로그램이 사용 중인 데이터를 메모리에서 실수로 지워버려, 나중에 그 데이터를 다시 쓰려고 할 때 오류나 해킹이 발생할 수 있는 문제입니다. 특정 설정(externref 사용 및 epoch interruption 활성화)이 켜져 있을 때만 발생합니다.
🇺🇸 원문 (English)
Wasmtime is a standalone JIT-style runtime for WebAssembly, using Cranelift. There is a use after free vulnerability in Wasmtime when both running Wasm that uses externrefs and enabling epoch interruption in Wasmtime. If you are not explicitly enabling epoch interruption (it is disabled by default) then you are not affected. If you are explicitly disabling the Wasm reference types proposal (it is enabled by default) then you are also not affected. The use after free is caused by Cranelift failing to emit stack maps when there are safepoints inside cold blocks. Cold blocks occur when epoch interruption is enabled. Cold blocks are emitted at the end of compiled functions, and change the order blocks are emitted versus defined. This reordering accidentally caused Cranelift to skip emitting some stack maps because it expected to emit the stack maps in block definition order, rather than block emission order. When Wasmtime would eventually collect garbage, it would fail to find live references on the stack because of the missing stack maps, think that they were unreferenced garbage, and therefore reclaim them. Then after the collection ended, the Wasm code could use the reclaimed-too-early references, which is a use after free. Patches have been released in versions 0.34.2 and 0.35.2, which fix the vulnerability. All Wasmtime users are recommended to upgrade to these patched versions. If upgrading is not an option for you at this time, you can avoid the vulnerability by either: disabling the Wasm reference types proposal, config.wasm_reference_types(false); or by disabling epoch interruption if you were previously enabling it. config.epoch_interruption(false).
📍 영향받는 시스템
Wasmtime (0.34.2 및 0.35.2 미만 버전 중 특정 설정 사용 시)
⚔️ 공격 벡터
특정 설정이 활성화된 Wasmtime 환경에서 조작된 WebAssembly 코드를 실행하여 메모리 오류 유도
🛡️ 대응 방법
Wasmtime를 0.34.2 또는 0.35.2 이상의 패치된 버전으로 업그레이드하거나, Wasm reference types 또는 epoch interruption 설정을 비활성화합니다.
🔧 검증 코드
출력된 Wasmtime 버전을 확인하여 0.34.2 또는 0.35.2 이상인지 체크합니다.
cargo run --version 2>/dev/null | grep -E 'Wasmtime'