# GHSA-3w9w-9833-gcpv: Security bug in ConvertToSinglePlane when used with untrusted content from the DDS loader

> A memory overwrite vulnerability in DirectXTex allows attackers to potentially execute code or cause denial of service via crafted planar video textures.

- **Severity:** Not scored
- **Exploited in the wild:** Not known
- **Login needed:** Not needed
- **Attackable:** Not stated
- **Victim action needed:** Not needed
- **Fix available:** Yes
- **Published:** 26 Jan 2023

## What is GHSA-3w9w-9833-gcpv?

GHSA-3w9w-9833-gcpv is a memory corruption vulnerability in directxtex_desktop_2019, published on 26 Jan 2023. 

### Official description

### Impact
A memory overwrite bug was reported by a security researcher in the **ConvertToSinglePlane** method via the *texconv* command-line tool when given an invalid height for planar video textures such as NV12. This can be a potential security bug for any clients of the library who follow the same pattern.

This issue *does not* impact use of the DDS texture loader itself, only when combined with `ConvertToSinglePlane` for converting multi-planar video formats. All other functions in the library fail immediately if given images in planar formats.

### Patches
The fix to the specific area as well as general hardening can be found in [this PR](https://github.com/microsoft/DirectXTex/pull/307) and will be included in the This bug has been fixed in the January 31, 2023 or later release of DirectXTex.

### Workarounds
If your code makes use of **ConvertToSinglePlane**, you can validate that the width & height alignment requirements are met for the input image before calling the function.

## Which versions are affected by GHSA-3w9w-9833-gcpv?

6 open source packages ship an affected version, including directxtex_desktop_2019, directxtex_desktop_win10 and directxtex_uwp.


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `directxtex_desktop_2019` | NuGet | All versions | 2023.1.31.1 |
| `directxtex_desktop_2019` | NuGet | All versions | 2023.1.31.1 |
| `directxtex_desktop_win10` | NuGet | All versions | 2023.1.31.1 |
| `directxtex_desktop_win10` | NuGet | All versions | 2023.1.31.1 |
| `directxtex_uwp` | NuGet | All versions | 2023.1.31.1 |
| `directxtex_uwp` | NuGet | All versions | 2023.1.31.1 |

## How do I fix GHSA-3w9w-9833-gcpv?

Upgrade directxtex_desktop_2019 to 2023.1.31.1 or later.

## Is GHSA-3w9w-9833-gcpv being exploited?

There is no known exploitation of GHSA-3w9w-9833-gcpv in the wild and no public exploit code.

## Fix prompt for AI coding agents

```text
Check this codebase for GHSA-3w9w-9833-gcpv and fix it if it is affected.

What it is: GHSA-3w9w-9833-gcpv is a memory corruption vulnerability in directxtex_desktop_2019, published on 26 Jan 2023. 
Exploitation: There is no known exploitation of GHSA-3w9w-9833-gcpv in the wild and no public exploit code.

Affected packages and fixed versions:
- directxtex_desktop_2019 (NuGet): affected all versions; fixed in 2023.1.31.1
- directxtex_desktop_2019 (NuGet): affected all versions; fixed in 2023.1.31.1
- directxtex_desktop_win10 (NuGet): affected all versions; fixed in 2023.1.31.1
- directxtex_desktop_win10 (NuGet): affected all versions; fixed in 2023.1.31.1
- directxtex_uwp (NuGet): affected all versions; fixed in 2023.1.31.1
- directxtex_uwp (NuGet): affected all versions; fixed in 2023.1.31.1

Task:
1. Search the dependency manifests and lockfiles (for example package.json, package-lock.json, requirements.txt, poetry.lock, uv.lock, pom.xml, build.gradle, go.mod, Cargo.lock, Gemfile.lock) and any Dockerfiles for the affected packages, including transitive dependencies.
2. If an affected version is in use, upgrade it to the fixed version for its release line with the project's package manager, so the lockfile is regenerated. Prefer the smallest upgrade that fixes it.
3. If there is no fix, or the upgrade would break the build, do not guess: explain the risk and the safest workaround instead.
4. Run the tests and summarise what changed and why.
5. If nothing in the project is affected, say so and change nothing.

Reference: https://insights.sbomify.com/GHSA-3w9w-9833-gcpv/ (Markdown: https://insights.sbomify.com/GHSA-3w9w-9833-gcpv/index.md)
```

## Sources

- OSV: https://osv.dev/vulnerability/GHSA-3w9w-9833-gcpv

---
From sbomify Insights: https://insights.sbomify.com/GHSA-3w9w-9833-gcpv/
Summaries are generated and may contain mistakes; the official description above is the record.
