# CVE-2023-45286: HTTP request body disclosure in github.com/go-resty/resty/v2

> A race condition in go-resty allows HTTP request body disclosure across requests when retries are enabled, potentially leaking sensitive data to unrelated servers.

- **Severity:** Medium 5.9 (`CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:H/I:N/A:N`)
- **Exploited in the wild:** Not known
- **Login needed:** Not needed
- **Attackable:** Over the internet
- **Victim action needed:** Not needed
- **Fix available:** Yes
- **Published:** 28 Nov 2023
- **Updated:** 28 Aug 2024
- **Also known as:** AZL-32050, DEBIAN-CVE-2023-45286, GHSA-xwh9-gc39-5298, GO-2023-2328, UBUNTU-CVE-2023-45286

## What is CVE-2023-45286?

CVE-2023-45286 is a medium-severity vulnerability in github.com/go-resty/resty/v2, published on 28 Nov 2023. An attacker can exploit it over the internet without logging in, with no action from the victim.

### Official description

A race condition in go-resty can result in HTTP request body disclosure across requests. This condition can be triggered by calling sync.Pool.Put with the same *bytes.Buffer more than once, when request retries are enabled and a retry occurs. The call to sync.Pool.Get will then return a bytes.Buffer that hasn't had bytes.Buffer.Reset called on it. This dirty buffer will contain the HTTP request body from an unrelated request, and go-resty will append the current HTTP request body to it, sending two bodies in one request. The sync.Pool in question is defined at package level scope, so a completely unrelated server could receive the request body.

Weakness: CWE-362 (Concurrent Execution using Shared Resource with Improper Synchronization)

## Which versions are affected by CVE-2023-45286?

3 open source packages ship an affected version, including github.com/go-resty/resty/v2. It affects 1 product.


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `github.com/go-resty/resty/v2` | Go | From 2.10.0 | 2.11.0 |
| `github.com/go-resty/resty/v2` | Go | From 2.10.0 | 2.11.0 |
| `github.com/go-resty/resty/v2` | Go | From 2.10.0 | 2.11.0 |

Products: Resty Project Resty.

## How do I fix CVE-2023-45286?

Upgrade github.com/go-resty/resty/v2 to 2.11.0 or later.

## Is CVE-2023-45286 being exploited?

There is no known exploitation of CVE-2023-45286 in the wild and no public exploit code.

## Fix prompt for AI coding agents

```text
Check this codebase for CVE-2023-45286 and fix it if it is affected.

What it is: CVE-2023-45286 is a medium-severity vulnerability in github.com/go-resty/resty/v2, published on 28 Nov 2023. An attacker can exploit it over the internet without logging in, with no action from the victim.
Exploitation: There is no known exploitation of CVE-2023-45286 in the wild and no public exploit code.

Affected packages and fixed versions:
- github.com/go-resty/resty/v2 (Go): affected from 2.10.0; fixed in 2.11.0
- github.com/go-resty/resty/v2 (Go): affected from 2.10.0; fixed in 2.11.0
- github.com/go-resty/resty/v2 (Go): affected from 2.10.0; fixed in 2.11.0

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/CVE-2023-45286/ (Markdown: https://insights.sbomify.com/CVE-2023-45286/index.md)
```

## Sources

- CVE record: https://www.cve.org/CVERecord?id=CVE-2023-45286
- NVD: https://nvd.nist.gov/vuln/detail/CVE-2023-45286
- OSV: https://osv.dev/vulnerability/CVE-2023-45286

---
From sbomify Insights: https://insights.sbomify.com/CVE-2023-45286/
Summaries are generated and may contain mistakes; the official description above is the record.
