GHSA-hfr4-7c6c-48w2
GHSA-hfr4-7c6c-48w2 is a Use After Free vulnerability in wasmtime. O3 Security confirms whether GHSA-hfr4-7c6c-48w2 is actually reachable in your code before you act, and blocks exploitation at runtime until you patch.
Wasmtime has use-after-free bug after cloning `wasmtime::Linker`
Blast Radius
wasmtimeReal-time download stats are indexed for npm and PyPI packages. This vulnerability affects crates.io packages — download data is not available via public APIs for these ecosystems.
Description
Impact
In version 43.0.0 of the wasmtime crate, cloning a wasmtime::Linker is unsound and can result in use-after-free bugs.
This bug is not controllable by guest Wasm programs. It can only be triggered by a specific sequence of embedder API calls made by the host.
The typical symptom of this use-after-free bug is a segfault. It does not enable heap corruption or data leakage.
If you are using the wasmtime CLI, rather than the embedding API, you are not affected. If you are using the embedding API but are not calling wasmtime::Linker's Clone implementation, you are not affected.
Specifically, the following steps must occur to trigger the bug:
- Clone a
wasmtime::Linker - Drop the original linker instance
- Use the new, cloned linker instance, resulting in a use-after-free
Patches
This bug has been patched in Wasmtime version 43.0.1
Workarounds
Wasmtime embedders are highly encouraged to upgrade their wasmtime crate dependency.
If upgrading is not an option, or as a temporary workaround before upgrading, you can avoid this bug by not cloning wasmtime::Linker and instead creating a new, empty wasmtime::Linker and manually reregistering the host APIs from the original linker:
use wasmtime::{Linker, Result, Store};
fn clone_linker<T>(linker: &Linker<T>, store: &mut Store<T>) -> Result<Linker<T>> {
let mut cloned = Linker::new();
for (module, name, item) in linker.iter(store) {
cloned.define(module, name, item)?;
}
Ok(cloned)
}
References
This bug was introduced during an internal refactoring that was part of our efforts to robustly handle allocation failure in Wasmtime. This refactoring introduced an string-interning pool which had an unsound TryClone1 implementation.
- The
StringPoolwas introduced in https://github.com/bytecodealliance/wasmtime/pull/12536, at which time the bug inTryClone for StringPoolwas already present, although this code path was not yet used anywhere. wasmtime::Linkerwas refactored to internally useStringPoolin https://github.com/bytecodealliance/wasmtime/pull/12537, at which time the buggy code path became accessible.- This bug was originally reported to the Wasmtime maintainers as https://github.com/bytecodealliance/wasmtime/pull/12906
Footnotes
-
The
TryClonetrait is our version of the Rust standard library'sClonetrait that allows for returningOutOfMemoryerrors. ↩
Affected Packages
| Ecosystem | Package | Vulnerable range | Fix |
|---|---|---|---|
| 🦀crates.io | wasmtime | ≥ 43.0.0&&< 43.0.1 | 43.0.1 |
Detection & mitigation playbook
Open-source dependencyDetect
Scan your dependency tree (package-lock.json, pnpm-lock.yaml, requirements.txt, go.sum, etc.) for wasmtime. O3's reachability analysis confirms whether the vulnerable code path is actually invoked in your application, so you act on real exposure instead of every transitive match.
Fix
Update wasmtime to 43.0.1 or later, then make sure no transitive (indirect) dependency still pins the vulnerable range — O3 confirms GHSA-hfr4-7c6c-48w2 is resolved across your whole dependency graph.
Workarounds
If you can't upgrade right away: gate or disable the affected feature, validate untrusted input at the boundary, and avoid passing attacker-controlled data into the vulnerable path. O3's runtime protection blocks exploitation in production as an interim safeguard until the upgrade lands.
How O3 protects you
O3 pinpoints whether GHSA-hfr4-7c6c-48w2 is reachable in your code and exactly where to fix it, then blocks exploitation in production at runtime until the patched version is deployed.
Tailored to GHSA-hfr4-7c6c-48w2. Runtime protection reduces exposure until a permanent patch is applied and verified — it complements patching, it doesn't replace it.
Frequently Asked Questions
Is GHSA-hfr4-7c6c-48w2 in your dependencies?
O3 detects GHSA-hfr4-7c6c-48w2 across crates.io dependencies and uses function-level reachability to confirm whether the vulnerable code path is actually reachable — not just present. No false positives.