|
| 1 | +```toml |
| 2 | +[advisory] |
| 3 | +id = "RUSTSEC-0000-0000" |
| 4 | +package = "lucet-runtime" |
| 5 | +date = "2021-11-30" |
| 6 | +url = "https://github.com/bytecodealliance/lucet/security/advisories/GHSA-hf79-8hjp-rrvq" |
| 7 | +# Valid categories: "code-execution", "crypto-failure", "denial-of-service", "file-disclosure" |
| 8 | +# "format-injection", "memory-corruption", "memory-exposure", "privilege-escalation" |
| 9 | +keywords = ["use after free"] |
| 10 | +aliases = ["CVE-2021-43790","GHSA-hf79-8hjp-rrvq"] |
| 11 | +cvss = "CVSS:3.1/AV:N/AC:H/PR:L/UI:N/S:C/C:H/I:H/A:H" |
| 12 | +license = "CC-BY-4.0" |
| 13 | + |
| 14 | +[versions] |
| 15 | +patched = [] |
| 16 | +unaffected = [] |
| 17 | + |
| 18 | +[affected] |
| 19 | +``` |
| 20 | + |
| 21 | +# Use After Free in lucet-runtime |
| 22 | + |
| 23 | +There is a bug in the main branch of Lucet's lucet-runtime |
| 24 | +that allows a use-after-free in an Instance object that could |
| 25 | +result in memory corruption, data race, or other related |
| 26 | +issues. This bug was introduced early in the development |
| 27 | +of Lucet and is present in all releases. As a result of |
| 28 | +this bug, and dependent on the memory backing for the |
| 29 | +Instance objects, it is possible to trigger a |
| 30 | +use-after-free when the Instance is dropped. |
| 31 | + |
| 32 | +## Patches |
| 33 | + |
| 34 | +Users should upgrade to the main branch of the Lucet |
| 35 | +repository. Lucet does not provide versioned releases on |
| 36 | +crates.io. |
| 37 | + |
| 38 | +## Workarounds |
| 39 | + |
| 40 | +There is no way to remediate this vulnerability without |
| 41 | +upgrading. |
| 42 | + |
| 43 | +## Description |
| 44 | + |
| 45 | +Lucet uses a "pool" allocator for new WebAssembly |
| 46 | +instances that are created. This pool allocator manages |
| 47 | +everything from the linear memory of the wasm instance, |
| 48 | +the runtime stack for async switching, as well as the |
| 49 | +memory behind the Instance itself. Instances are referred |
| 50 | +to via an InstanceHandle type which will, on drop, |
| 51 | +release the memory backing the Instance back to the pool. |
| 52 | + |
| 53 | +When an Instance is dropped, the fields of the Instance |
| 54 | +are destructed top-to-bottom, however when the alloc: |
| 55 | +Alloc field is destructed, the memory backing the |
| 56 | +Instance is released back to the pool before the |
| 57 | +destructors of the remaining fields are run. If another |
| 58 | +thread allocates the same memory from the pool while |
| 59 | +these destructors are still running, a race condition |
| 60 | +occurs that can lead to use-after-free errors. |
| 61 | + |
| 62 | +The bug was corrected by changing how the InstanceHandle |
| 63 | +destructor operates to ensure that the memory backing an |
| 64 | +Instance is only returned to the pool once the Instance |
| 65 | +has been completely destroyed. |
0 commit comments