# CVE-2023-23626: Denial of service when feeding malformed size arguments in go-bitfield

> Attackers can cause a denial of service by providing malformed size arguments to go-bitfield functions, triggering panics in applications using the library.

- **Severity:** Medium 5.9 (`CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:N/I:N/A:H`)
- **Exploited in the wild:** Not known
- **Login needed:** Not needed
- **Attackable:** Over the internet
- **Victim action needed:** Not needed
- **Fix available:** Yes
- **Published:** 9 Feb 2023
- **Updated:** 10 Mar 2025
- **Also known as:** GHSA-2h6c-j3gf-xp9r, GO-2023-1558

## What is CVE-2023-23626?

CVE-2023-23626 is a medium-severity denial of service vulnerability in ipfs go-bitfield, published on 9 Feb 2023. An attacker can exploit it over the internet without logging in, with no action from the victim.

### Official description

go-bitfield is a simple bitfield package for the go language aiming to be more performant that the standard library. When feeding untrusted user input into the size parameter of `NewBitfield` and `FromBytes` functions, an attacker can trigger `panic`s. This happen when the `size` is a not a multiple of `8` or is negative. There were already a note in the `NewBitfield` documentation, however known users of this package are subject to this issue. Users are advised to upgrade. Users unable to upgrade should ensure that `size` is a multiple of 8 before calling `NewBitfield` or `FromBytes`.

Weakness: CWE-1284 (Improper Validation of Specified Quantity in Input), CWE-754 (Improper Check for Unusual or Exceptional Conditions)

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

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


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `github.com/ipfs/go-bitfield` | Go | All versions | 1.1.0 |
| `github.com/ipfs/go-bitfield` | Go | All versions | 1.1.0 |
| `github.com/ipfs/go-bitfield` | Go | All versions | 1.1.0 |

Products: Protocol Go-Bitfield.

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

Upgrade github.com/ipfs/go-bitfield to 1.1.0 or later.

## Is CVE-2023-23626 being exploited?

It is not confirmed as exploited in the wild, but public exploit code for CVE-2023-23626 exists.

## Fix prompt for AI coding agents

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

What it is: CVE-2023-23626 is a medium-severity denial of service vulnerability in ipfs go-bitfield, published on 9 Feb 2023. An attacker can exploit it over the internet without logging in, with no action from the victim.
Exploitation: It is not confirmed as exploited in the wild, but public exploit code for CVE-2023-23626 exists.

Affected packages and fixed versions:
- github.com/ipfs/go-bitfield (Go): affected all versions; fixed in 1.1.0
- github.com/ipfs/go-bitfield (Go): affected all versions; fixed in 1.1.0
- github.com/ipfs/go-bitfield (Go): affected all versions; fixed in 1.1.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-23626/ (Markdown: https://insights.sbomify.com/CVE-2023-23626/index.md)
```

## Sources

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

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