{"id":"CVE-2022-39394","aliases":["CVE-2022-39394","GHSA-h84q-m8rr-3v9q","RUSTSEC-2022-0097"],"related":[],"kind":"vulnerability","state":"published","title":"wasmtime_trap_code C API function has out of bounds write vulnerability","summary":"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.","summarySource":"cvelist","descriptions":[{"lang":"en","text":"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.","source":"cvelist"},{"lang":"en","text":"### Impact\n\nThere 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.\n\n### Patches\n\nThis bug has been patched and users should upgrade to Wasmtime 2.0.2.\n\n### Workarounds\n\nThis 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.\n\n### References\n\n* [Definition of `wasmtime_trap_code`](https://docs.wasmtime.dev/c-api/trap_8h.html#a6580f4f209d3eaebb6e8b9a901a30b7a)\n* [Mailing list announcement](https://groups.google.com/a/bytecodealliance.org/g/sec-announce/c/c1HBDDJwNPA)\n* [Patch to fix for `main` branch](https://github.com/bytecodealliance/wasmtime/commit/5b6d5e78de106503b3b9add218bb3d2b1d63c493)\n\n### For more information\n\nIf you have any questions or comments about this advisory:\n\n* Reach out to us on [the Bytecode Alliance Zulip chat](https://bytecodealliance.zulipchat.com/#narrow/stream/217126-wasmtime)\n* Open an issue in [the bytecodealliance/wasmtime repository](https://github.com/bytecodealliance/wasmtime/)","format":"markdown","source":"ghsa"},{"lang":"en","text":"This is an entry in the RustSec database for the Wasmtime security advisory\nlocated at\nhttps://github.com/bytecodealliance/wasmtime/security/advisories/GHSA-h84q-m8rr-3v9q.\nFor more information see the GitHub-hosted security advisory.","format":"markdown","source":"rustsec"},{"lang":"es","text":"Wasmtime es un tiempo de ejecución independiente para WebAssembly. Antes de la versión 2.0.2, había un error en la implementación de la API C de Wasmtime donde la definición de `wasmtime_trap_code` no coincide con su firma declarada en el archivo de encabezado `wasmtime/trap.h`. Esta discrepancia hace que la implementación de la función realice una escritura de 4 bytes en un búfer de 1 byte proporcionado por la persona que llama. Esto puede provocar que se escriban tres bytes cero más allá de la ubicación de 1 byte proporcionada por la persona que llama. Este error ha sido corregido y los usuarios deben actualizar a Wasmtime 2.0.2. Este error se puede solucionar proporcionando un búfer de 4 bytes convertido a un búfer de 1 byte al llamar a `wasmtime_trap_code`. Los usuarios de la caja `wasmtime` no se ven afectados por este problema, solo los usuarios de la función API de C `wasmtime_trap_code` se ven afectados.","source":"nvd"}],"published":"2022-11-07T12:00:00.000Z","modified":"2026-10-12T18:00:06.112Z","severity":{"scorer":"GitHub_M","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:L/AC:H/PR:H/UI:R/S:U/C:L/I:L/A:L","score":3.8,"rating":"LOW"},"severities":[{"scorer":"GitHub_M","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:L/AC:H/PR:H/UI:R/S:U/C:L/I:L/A:L","score":3.8,"rating":"LOW"},{"scorer":"GitHub","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:L/AC:H/PR:H/UI:R/S:U/C:L/I:L/A:L","score":3.8,"rating":"LOW"},{"scorer":"RustSec Advisory Database","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:L/AC:H/PR:H/UI:R/S:U/C:L/I:L/A:L","score":3.8,"rating":"LOW"},{"scorer":"NVD","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H","score":9.8,"rating":"CRITICAL"}],"cwes":["CWE-787"],"affected":[{"ranges":[{"version":"< 2.0.2","status":"affected"}],"vendor":"bytecodealliance","product":"wasmtime","source":"cvelist"},{"ranges":[{"type":"semver","introduced":"2.0.0","status":"affected","fixed":"2.0.2"}],"ecosystem":"crates.io","package":"wasmtime","purl":"pkg:cargo/wasmtime","source":"ghsa"},{"ranges":[{"type":"semver","introduced":"0","status":"affected","fixed":"1.0.2"}],"ecosystem":"crates.io","package":"wasmtime","purl":"pkg:cargo/wasmtime","source":"ghsa"},{"ranges":[{"type":"semver","introduced":"0.0.0-0","status":"affected","fixed":"1.0.2"},{"type":"semver","introduced":"2.0.0","status":"affected","fixed":"2.0.2"}],"ecosystem":"crates.io","package":"wasmtime","purl":"pkg:cargo/wasmtime","source":"rustsec"},{"ranges":[{"status":"affected","fixed":"1.0.2"},{"status":"affected","introduced":"2.0.0","fixed":"2.0.2"}],"vendor":"bytecodealliance","product":"wasmtime","cpe":"cpe:2.3:a:bytecodealliance:wasmtime:*:*:*:*:*:rust:*:*","source":"nvd"}],"references":[{"url":"https://github.com/bytecodealliance/wasmtime/security/advisories/GHSA-h84q-m8rr-3v9q","tags":["third-party-advisory","web","x-transferred"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://github.com/bytecodealliance/wasmtime/commit/087d9d7becf7422b3f872a3bcd5d97bb7ce7ff36","tags":["patch","third-party-advisory","web","x-transferred"],"sources":["cvelist","ghsa","rustsec","nvd"]},{"url":"https://nvd.nist.gov/vuln/detail/CVE-2022-39394","tags":["advisory"],"sources":["ghsa"]},{"url":"https://github.com/bytecodealliance/wasmtime/commit/5b6d5e78de106503b3b9add218bb3d2b1d63c493","tags":["web"],"sources":["ghsa"]},{"url":"https://github.com/bytecodealliance/wasmtime","tags":["package"],"sources":["ghsa"]},{"url":"https://groups.google.com/a/bytecodealliance.org/g/sec-announce/c/c1HBDDJwNPA","tags":["web"],"sources":["ghsa"]},{"url":"https://rustsec.org/advisories/RUSTSEC-2022-0097.html","tags":["advisory","web"],"sources":["ghsa","rustsec"]},{"url":"https://crates.io/crates/wasmtime","tags":["package"],"sources":["rustsec"]}],"credits":[],"assigner":"GitHub_M","ssvc":{"scorer":"CISA-ADP","exploitation":"none","automatable":"no","technicalImpact":"partial","date":"2025-04-23T13:54:57.843Z"},"sources":[{"source":"cvelist","name":"CVE List","id":"CVE-2022-39394","url":"https://www.cve.org/CVERecord?id=CVE-2022-39394","licence":"CVE Terms of Use","modified":"2025-04-23T16:39:05.163Z"},{"source":"ghsa","name":"GitHub Advisory Database","id":"GHSA-h84q-m8rr-3v9q","url":"https://github.com/advisories/GHSA-h84q-m8rr-3v9q","licence":"CC-BY-4.0","modified":"2025-05-02T12:51:45.000Z"},{"source":"rustsec","name":"RustSec Advisory Database","id":"RUSTSEC-2022-0097","url":"https://rustsec.org/advisories/RUSTSEC-2022-0097.html","licence":"CC0-1.0","modified":"2026-10-12T18:00:06.112Z"},{"source":"nvd","name":"NVD","id":"CVE-2022-39394","url":"https://nvd.nist.gov/vuln/detail/CVE-2022-39394","licence":"Public domain","modified":"2026-06-17T04:58:16.460Z"}],"updatedAt":"2026-11-25T22:58:16.387Z","epss":{"score":0.00433,"percentile":0.39367,"date":"2026-12-01T12:00:22.000Z"}}