// For flags

CVE-2021-39216

Use after free passing `externref`s to Wasm in Wasmtime

Severity Score

6.3
*CVSS v3.1

Exploit Likelihood

*EPSS

Affected Versions

*CPE

Public Exploits

0
*Multiple Sources

Exploited in Wild

-
*KEV

Decision

-
*SSVC
Descriptions

Wasmtime is an open source runtime for WebAssembly & WASI. In Wasmtime from version 0.19.0 and before version 0.30.0 there was a use-after-free bug when passing `externref`s from the host to guest Wasm content. To trigger the bug, you have to explicitly pass multiple `externref`s from the host to a Wasm instance at the same time, either by passing multiple `externref`s as arguments from host code to a Wasm function, or returning multiple `externref`s to Wasm from a multi-value return function defined in the host. If you do not have host code that matches one of these shapes, then you are not impacted. If Wasmtime's `VMExternRefActivationsTable` became filled to capacity after passing the first `externref` in, then passing in the second `externref` could trigger a garbage collection. However the first `externref` is not rooted until we pass control to Wasm, and therefore could be reclaimed by the collector if nothing else was holding a reference to it or otherwise keeping it alive. Then, when control was passed to Wasm after the garbage collection, Wasm could use the first `externref`, which at this point has already been freed. We have reason to believe that the effective impact of this bug is relatively small because usage of `externref` is currently quite rare. The bug has been fixed, and users should upgrade to Wasmtime 0.30.0. If you cannot upgrade Wasmtime yet, you can avoid the bug by disabling reference types support in Wasmtime by passing `false` to `wasmtime::Config::wasm_reference_types`.

Wasmtime es un tiempo de ejecución de código abierto para WebAssembly y WASI. En Wasmtime desde la versión 0.19.0 y versiones anteriores a 0.30.0, se presentaba un error de uso de memoria previamente liberada cuando se pasaban "externref"s desde el host al contenido del Wasm invitado. Para desencadenar el bug, debes pasar explícitamente múltiples "externref"s desde el host a una instancia de Wasm al mismo tiempo, ya sea pasando múltiples "externref"s como argumentos desde el código del host a una función de Wasm, o devolviendo múltiples "externref"s a Wasm desde una función de retorno multivalente definida en el host. Si no tienes código de host que coincida con una de estas formas, entonces no te afecta. Si la "VMExternRefActivationsTable" de Wasmtime se llenó de capacidad después de pasar la primera "externref", entonces pasar la segunda "externref" podría desencadenar una recolección de basura. Sin embargo, la primera "externref" no está arraigada hasta que pasamos el control a Wasm, y por lo tanto podría ser recuperada por el recolector si nada más estuviera manteniendo una referencia a ella o la mantuviera viva. Entonces, cuando se pasara el control a Wasm después de la recolección de basura, Wasm podría usar la primera "externref", que en este punto ya ha sido liberada. Tenemos razones para creer que el impacto efectivo de este error es relativamente pequeño porque el uso de "externref" es actualmente bastante raro. El bug ha sido corregido, y los usuarios deberían actualizar a Wasmtime versión 0.30.0. Si no puedes actualizar Wasmtime todavía, puedes evitar el bug deshabilitando el soporte de tipos de referencia en Wasmtime pasando "false" a "wasmtime::Config::wasm_reference_types"

*Credits: N/A
CVSS Scores
Attack Vector
Local
Attack Complexity
High
Privileges Required
Low
User Interaction
None
Scope
Unchanged
Confidentiality
None
Integrity
High
Availability
High
Attack Vector
Local
Attack Complexity
Medium
Authentication
None
Confidentiality
None
Integrity
Partial
Availability
Partial
* Common Vulnerability Scoring System
SSVC
  • Decision:-
Exploitation
-
Automatable
-
Tech. Impact
-
* Organization's Worst-case Scenario
Timeline
  • 2021-08-16 CVE Reserved
  • 2021-09-17 CVE Published
  • 2023-03-08 EPSS Updated
  • 2024-08-04 CVE Updated
  • ---------- Exploited in Wild
  • ---------- KEV Due Date
  • ---------- First Exploit
CWE
  • CWE-416: Use After Free
CAPEC
Affected Vendors, Products, and Versions
Vendor Product Version Other Status
Vendor Product Version Other Status <-- --> Vendor Product Version Other Status
Bytecodealliance
Search vendor "Bytecodealliance"
Wasmtime
Search vendor "Bytecodealliance" for product "Wasmtime"
>= 0.19.0 < 0.30.0
Search vendor "Bytecodealliance" for product "Wasmtime" and version " >= 0.19.0 < 0.30.0"
-
Affected
Fedoraproject
Search vendor "Fedoraproject"
Fedora
Search vendor "Fedoraproject" for product "Fedora"
34
Search vendor "Fedoraproject" for product "Fedora" and version "34"
-
Affected
Fedoraproject
Search vendor "Fedoraproject"
Fedora
Search vendor "Fedoraproject" for product "Fedora"
35
Search vendor "Fedoraproject" for product "Fedora" and version "35"
-
Affected