# GHSA-87m9-rv8p-rgmg: go-grpc-compression has a zstd decompression bombing vulnerability

> A malicious user can cause denial of service via crafted gRPC requests due to unbounded zstd decompression, requiring library upgrades.

- **Severity:** Not scored
- **Exploited in the wild:** Not known
- **Login needed:** Not needed
- **Attackable:** Over the internet
- **Victim action needed:** Not needed
- **Fix available:** Yes
- **Published:** 10 Jun 2024
- **Also known as:** GO-2024-2911

## What is GHSA-87m9-rv8p-rgmg?

GHSA-87m9-rv8p-rgmg is a denial of service vulnerability in github.com/mostynb/go-grpc-compression, published on 10 Jun 2024. An attacker can exploit it over the internet without logging in, with no action from the victim.

### Official description

### Impact

A malicious user could cause a denial of service (DoS) when using a specially crafted gRPC request. The decompression mechanism for zstd did not respect the limits imposed by gRPC, allowing rapid memory usage increases.

Versions v1.1.4 through to v1.2.2 made use of the Decoder.DecodeAll function in github.com/klauspost/compress/zstd to decompress data provided by the peer. The vulnerability is exploitable only by attackers who can send gRPC payloads to users of github.com/mostynb/go-grpc-compression/zstd or github.com/mostynb/go-grpc-compression/nonclobbering/zstd.

### Patches

Version v1.2.3  of github.com/mostynb/go-grpc-compression avoids the issue by not using the Decoder.DecodeAll function in github.com/klauspost/compress/zstd.

All users of github.com/mostynb/go-grpc-compression/zstd or github.com/mostynb/go-grpc-compression/nonclobbering/zstd in the affected versions should update to v1.2.3.

### Workarounds

Other compression formats were not affected, users may consider switching from zstd to another format without upgrading to a newer release.

### References

This issue was uncovered during a security audit performed by [Miroslav Stampar](https://github.com/stamparm/) of [7ASecurity](https://7asecurity.com/), facilitated by [OSTIF](https://ostif.org/), for the OpenTelemetry project.

https://opentelemetry.io/blog/2024/cve-2024-36129
https://github.com/open-telemetry/opentelemetry-collector/security/advisories/GHSA-c74f-6mfw-mm4v

## Which versions are affected by GHSA-87m9-rv8p-rgmg?

3 open source packages ship an affected version, including github.com/mostynb/go-grpc-compression.


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `github.com/mostynb/go-grpc-compression` | Go | From 1.1.4 | 1.2.3 |
| `github.com/mostynb/go-grpc-compression` | Go | From 1.1.4 | 1.2.3 |
| `github.com/mostynb/go-grpc-compression` | Go | From 1.1.4 | 1.2.3 |

## How do I fix GHSA-87m9-rv8p-rgmg?

Upgrade github.com/mostynb/go-grpc-compression to 1.2.3 or later.

## Is GHSA-87m9-rv8p-rgmg being exploited?

There is no known exploitation of GHSA-87m9-rv8p-rgmg in the wild and no public exploit code.

## Fix prompt for AI coding agents

```text
Check this codebase for GHSA-87m9-rv8p-rgmg and fix it if it is affected.

What it is: GHSA-87m9-rv8p-rgmg is a denial of service vulnerability in github.com/mostynb/go-grpc-compression, published on 10 Jun 2024. An attacker can exploit it over the internet without logging in, with no action from the victim.
Exploitation: There is no known exploitation of GHSA-87m9-rv8p-rgmg in the wild and no public exploit code.

Affected packages and fixed versions:
- github.com/mostynb/go-grpc-compression (Go): affected from 1.1.4; fixed in 1.2.3
- github.com/mostynb/go-grpc-compression (Go): affected from 1.1.4; fixed in 1.2.3
- github.com/mostynb/go-grpc-compression (Go): affected from 1.1.4; fixed in 1.2.3

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-87m9-rv8p-rgmg/ (Markdown: https://insights.sbomify.com/GHSA-87m9-rv8p-rgmg/index.md)
```

## Sources

- OSV: https://osv.dev/vulnerability/GHSA-87m9-rv8p-rgmg

---
From sbomify Insights: https://insights.sbomify.com/GHSA-87m9-rv8p-rgmg/
Summaries are generated and may contain mistakes; the official description above is the record.
