# CVE-2022-23495: ProtoNode may be modified such that common method calls may panic in ipfs/go-merkledag

> Attackers can cause a panic in the go-merkledag library by manipulating ProtoNode states, leading to denial of service in applications using this IPFS component.

- **Severity:** High 7.5 (`CVSS:3.1/AV:N/AC:L/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:** 8 Dec 2022
- **Updated:** 23 Apr 2025
- **Also known as:** GHSA-x39j-h85h-3f46, GO-2022-1155

## What is CVE-2022-23495?

CVE-2022-23495 is a high-severity denial of service vulnerability in ipfs go-merkledag, published on 8 Dec 2022. An attacker can exploit it over the internet without logging in, with no action from the victim.

### Official description

go-merkledag implements the 'DAGService' interface and adds two ipld node types, Protobuf and Raw for the ipfs project. A `ProtoNode` may be modified in such a way as to cause various encode errors which will trigger a panic on common method calls that don't allow for error returns. A `ProtoNode` should only be able to encode to valid DAG-PB, attempting to encode invalid DAG-PB forms will result in an error from the codec. Manipulation of an existing (newly created or decoded) `ProtoNode` using the modifier methods did not account for certain states that would place the `ProtoNode` into an unencodeable form. Due to conformance with the [`github.com/ipfs/go-block-format#Block`](https://pkg.go.dev/github.com/ipfs/go-block-format#Block) and [`github.com/ipfs/go-ipld-format#Node`](https://pkg.go.dev/github.com/ipfs/go-ipld-format#Node) interfaces, certain methods, which internally require a re-encode if state has changed, will panic due to the inability to return an error. This issue has been addressed across a number of pull requests. Users are advised to upgrade to version 0.8.1 for a complete set of fixes. Users unable to upgrade may attempt to mitigate this issue by sanitising inputs when allowing user-input to set a new `CidBuilder` on a `ProtoNode` and by sanitising `Tsize` (`Link#Size`) values such that they are a reasonable byte-size for sub-DAGs where derived from user-input.

Weakness: CWE-252 (Unchecked Return Value), CWE-755 (Improper Handling of Exceptional Conditions)

## Which versions are affected by CVE-2022-23495?

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


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `github.com/ipfs/go-merkledag` | Go | From 0.4.0 | 0.8.1 |
| `github.com/ipfs/go-merkledag` | Go | From 0.4.0 | 0.8.1 |
| `github.com/ipfs/go-merkledag` | Go | From 0.4.0 | 0.8.1 |

Products: Protocol Go-Merkledag.

## How do I fix CVE-2022-23495?

Upgrade github.com/ipfs/go-merkledag to 0.8.1 or later.

## Is CVE-2022-23495 being exploited?

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

## Fix prompt for AI coding agents

```text
Check this codebase for CVE-2022-23495 and fix it if it is affected.

What it is: CVE-2022-23495 is a high-severity denial of service vulnerability in ipfs go-merkledag, published on 8 Dec 2022. 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-2022-23495 in the wild and no public exploit code.

Affected packages and fixed versions:
- github.com/ipfs/go-merkledag (Go): affected from 0.4.0; fixed in 0.8.1
- github.com/ipfs/go-merkledag (Go): affected from 0.4.0; fixed in 0.8.1
- github.com/ipfs/go-merkledag (Go): affected from 0.4.0; fixed in 0.8.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/CVE-2022-23495/ (Markdown: https://insights.sbomify.com/CVE-2022-23495/index.md)
```

## Sources

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

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