# GHSA-h6gw-r52c-724r: NULL Pointer Dereference and Access of Uninitialized Pointer in TensorFlow

> Attackers can trigger denial of service or read/write out-of-bounds memory via missing validation in TensorFlow's boosted trees implementation.

- **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:** 9 Feb 2022

## What is GHSA-h6gw-r52c-724r?

GHSA-h6gw-r52c-724r is a vulnerability in tensorflow, published on 9 Feb 2022. 

### Official description

### Impact 
The [code for boosted trees in TensorFlow](https://github.com/tensorflow/tensorflow/blob/e0b6e58c328059829c3eb968136f17aa72b6c876/tensorflow/core/kernels/boosted_trees/stats_ops.cc) is still missing validation. This allows malicious users to read and write outside of bounds of heap allocated data as well as trigger denial of service (via dereferencing `nullptr`s or via `CHECK`-failures).

This follows after CVE-2021-41208 where these APIs were still vulnerable to multiple security issues.

**Note**: Given that the boosted trees implementation in TensorFlow is unmaintained, it is recommend to no longer use these APIs.  Instead, please use the downstream [TensorFlow Decision Forests](https://github.com/tensorflow/decision-forests) project which is newer and supports more features. 
  
These APIs are now deprecated in TensorFlow 2.8. We will remove TensorFlow's boosted trees APIs in subsequent releases.
  
### Patches
We have patched the known issues in multiple GitHub commits.
  
The fix will be included in TensorFlow 2.8.0. We will also cherrypick this commit on TensorFlow 2.7.1, TensorFlow 2.6.3, and TensorFlow 2.5.3, as these are also affected and still in supported range.

This should allow users to use existing boosted trees APIs for a while until they migrate to [TensorFlow Decision Forests](https://github.com/tensorflow/decision-forests), while guaranteeing that known vulnerabilities are fixed.

### For more information
Please consult [our security guide](https://github.com/tensorflow/tensorflow/blob/master/SECURITY.md) for more information regarding the security model and how to contact us with issues and questions.

### Attribution
These vulnerabilities have been reported by Yu Tian of Qihoo 360 AIVul Team and Faysal Hossain Shezan from University of Virginia. Some of the issues have been discovered internally after a careful audit of the APIs.

## Which versions are affected by GHSA-h6gw-r52c-724r?

18 open source packages ship an affected version, including tensorflow, tensorflow-cpu and tensorflow-gpu.


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `tensorflow` | PyPI | All versions | 2.5.3 |
| `tensorflow` | PyPI | All versions | 2.5.3 |
| `tensorflow` | PyPI | From 2.6.0 | 2.6.3 |
| `tensorflow` | PyPI | From 2.6.0 | 2.6.3 |
| `tensorflow` | PyPI | From 2.7.0 | 2.7.1 |
| `tensorflow` | PyPI | From 2.7.0 | 2.7.1 |
| `tensorflow-cpu` | PyPI | All versions | 2.5.3 |
| `tensorflow-cpu` | PyPI | All versions | 2.5.3 |
| `tensorflow-cpu` | PyPI | From 2.6.0 | 2.6.3 |
| `tensorflow-cpu` | PyPI | From 2.6.0 | 2.6.3 |
| `tensorflow-cpu` | PyPI | From 2.7.0 | 2.7.1 |
| `tensorflow-cpu` | PyPI | From 2.7.0 | 2.7.1 |
| `tensorflow-gpu` | PyPI | All versions | 2.5.3 |
| `tensorflow-gpu` | PyPI | All versions | 2.5.3 |
| `tensorflow-gpu` | PyPI | From 2.6.0 | 2.6.3 |
| `tensorflow-gpu` | PyPI | From 2.6.0 | 2.6.3 |
| `tensorflow-gpu` | PyPI | From 2.7.0 | 2.7.1 |
| `tensorflow-gpu` | PyPI | From 2.7.0 | 2.7.1 |

## How do I fix GHSA-h6gw-r52c-724r?

Upgrade tensorflow to a fixed version for your release line: 2.5.3, 2.6.3 or 2.7.1.

## Is GHSA-h6gw-r52c-724r being exploited?

There is no known exploitation of GHSA-h6gw-r52c-724r in the wild and no public exploit code.

## Fix prompt for AI coding agents

```text
Check this codebase for GHSA-h6gw-r52c-724r and fix it if it is affected.

What it is: GHSA-h6gw-r52c-724r is a vulnerability in tensorflow, published on 9 Feb 2022. 
Exploitation: There is no known exploitation of GHSA-h6gw-r52c-724r in the wild and no public exploit code.

Affected packages and fixed versions:
- tensorflow (PyPI): affected all versions; fixed in 2.5.3
- tensorflow (PyPI): affected all versions; fixed in 2.5.3
- tensorflow (PyPI): affected from 2.6.0; fixed in 2.6.3
- tensorflow (PyPI): affected from 2.6.0; fixed in 2.6.3
- tensorflow (PyPI): affected from 2.7.0; fixed in 2.7.1
- tensorflow (PyPI): affected from 2.7.0; fixed in 2.7.1
- tensorflow-cpu (PyPI): affected all versions; fixed in 2.5.3
- tensorflow-cpu (PyPI): affected all versions; fixed in 2.5.3
- tensorflow-cpu (PyPI): affected from 2.6.0; fixed in 2.6.3
- tensorflow-cpu (PyPI): affected from 2.6.0; fixed in 2.6.3
- tensorflow-cpu (PyPI): affected from 2.7.0; fixed in 2.7.1
- tensorflow-cpu (PyPI): affected from 2.7.0; fixed in 2.7.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-h6gw-r52c-724r/ (Markdown: https://insights.sbomify.com/GHSA-h6gw-r52c-724r/index.md)
```

## Sources

- OSV: https://osv.dev/vulnerability/GHSA-h6gw-r52c-724r

---
From sbomify Insights: https://insights.sbomify.com/GHSA-h6gw-r52c-724r/
Summaries are generated and may contain mistakes; the official description above is the record.
