Executive brief
stb is a popular single-file C library collection used in games, graphics tools, and other performance-critical applications. A buffer overflow vulnerability in its sprintf implementation allows attackers to write a null byte one position before a caller-provided buffer, corrupting adjacent memory and potentially causing application crashes or code execution.
Technical details
An out-of-bounds write vulnerability exists in stbsp_vsnprintf() (stb_sprintf.h) when called with count=0 and a non-NULL buffer. The null-termination logic computes a negative offset (l = -1), writing buf[-1] = 0. The root cause is missing bounds validation: when count=0, the internal callback clamps output to 0 bytes, but the subsequent null-terminator write does not account for this edge case. Attack vector requires calling stbsp_snprintf() with adversarial count and buffer parameters; no network reachability or authentication is required. An attacker can corrupt heap or stack memory adjacent to the target buffer. A patch is pending; workarounds include validating count > 0 before calling stbsp_snprintf().
Affected products
- nothings stb commit 31c1ad3 and prior
Timeline
- 2026-06-06: disclosed: Issue reported on GitHub #1963
- 2026-09-09: advisory: CVE-2026-79516 published