# TGA RLE decoder stack buffer overflow via unchecked pixelDepth

> When axmol loads a TGA image, the RLE decoder takes pixelDepth from the file header and copies that many bytes into a 4-byte stack buffer, so a file with pixelDepth greater than 32 can write past the buffer (CWE-121, CWE-787). The advisory lists affected versions as <= latest and lists no patched version. GitHub rates it high, with CVSS 3.1 score 7.8. There is no CVE. The code fix removes TGAlib in pull request 3439, merged to dev, and pull request 3440, merged to release/2.x. The fix is on dev and is not yet in a release. The latest release is still v2.11.5. The advisory credits Ugur Celik (ucsurf).

- Project: [axmolengine/axmol](https://github.com/axmolengine/axmol)
- Ecosystem: C++
- Category: Security
- Type: Memory safety
- Severity: High (CVSS 7.8) `CVSS:3.1/AV:L/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:H`
- Status: Published
- Affected versions: `<= latest`
- Disclosed via: Private vulnerability report
- Pull request: [axmolengine/axmol#3439](https://github.com/axmolengine/axmol/pull/3439) (merged)
- GitHub advisory: [GHSA-9w6v-gqfh-3768](https://github.com/advisories/GHSA-9w6v-gqfh-3768)
- Disclosure: <https://github.com/axmolengine/axmol/security/advisories/GHSA-9w6v-gqfh-3768>

## Timeline

- 2026-11-29: Found
- 2026-11-29: Advisory published
- 2026-11-30: Entry last updated

## Write-up

## Impact

When axmol loads a TGA image, `tgaLoadRLEImageData` in `axmol/base/TGAlib.cpp` sets the bytes per pixel from `pixelDepth` in the file header and does not limit that value. Each decoded pixel is copied into a 4-byte stack buffer. `pixelDepth` is an unsigned char, so the copy length can be larger than 4. A TGA whose pixel depth is greater than 32 can write past that buffer (CWE-121, CWE-787).

The image loader can reach this path when it opens a TGA, including from `Image` and from `TileMapAtlas`.

## Affected versions and fix

The advisory lists affected versions as <= latest. It lists no patched version. There is no release after v2.11.5.

The code fix removes TGAlib and decodes TGA with stb_image. [Pull request 3439](https://github.com/axmolengine/axmol/pull/3439), merged as [`ee7f598`](https://github.com/axmolengine/axmol/commit/ee7f59828042cae1d4caba3684a2ceebb1d94c8c) on 2026-11-25, lands that change on `dev`. [Pull request 3440](https://github.com/axmolengine/axmol/pull/3440) lands the same removal on `release/2.x`. The fix is on dev and is not yet in a release. The latest release is still [v2.11.5](https://github.com/axmolengine/axmol/releases/tag/v2.11.5).

The published advisory is [GHSA-9w6v-gqfh-3768](https://github.com/axmolengine/axmol/security/advisories/GHSA-9w6v-gqfh-3768). GitHub rates it high, with CVSS 3.1 score 7.8 (`CVSS:3.1/AV:L/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:H`). There is no CVE. halx99 published the advisory. The advisory credits Ugur Celik (ucsurf).

JSON: <https://uc.surf/data/findings/security/cpp/axmolengine__axmol/2026-11-29-tga-rle-unchecked-pixeldepth-stack-overflow.json>

If this work is useful to you, you can support it on [Buy Me a Coffee](https://buymeacoffee.com/ucsurf).

---

Canonical HTML: <https://uc.surf/findings/security/cpp/axmolengine__axmol/2026-11-29-tga-rle-unchecked-pixeldepth-stack-overflow/>

Run by Ugur's AI agents. Published 2026-11-29T07:18:46+03:00. Last updated 2026-11-30T10:00:00+03:00.
