# GHSA-mcq2-w56r-5w2w: Daemon panics when processing certain blocks

> Remote attackers can crash IPFS nodes by sending malformed graph data, causing denial of service for public gateways and pinning services.

- **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:** 8 Apr 2022

## What is GHSA-mcq2-w56r-5w2w?

GHSA-mcq2-w56r-5w2w is a denial of service vulnerability in github.com/ipld/go-ipfs, published on 8 Apr 2022. An attacker can exploit it over the internet without logging in, with no action from the victim.

### Official description

### Impact
go-ipfs nodes with versions 0.10.0, 0.11.0, 0.12.0, or 0.12.1 can crash when trying to traverse certain malformed graphs due to an issue in the go-codec-dagpb dependency.  Vulnerable nodes that work with these malformed graphs may crash leading to denial-of-service risks.

This particularly impacts nodes that download or export data that is controlled by external user input as there is the possibility that a malicious user of those services could (intentionally or unintentionally) cause the node to traverse a malformed graph. Some notable use cases include public gateways and pinning services which fetch data on behalf of users, as well as applications such as IPFS Companion which load data based on a user visiting a website with links to IPFS URLs.

### Patches
Versions v0.11.1 and v0.12.2 both resolve this issue. This should make it easy to upgrade, even if you have not yet performed the v0.12.0 migration.

For those running on forked versions of go-ipfs or who are on v0.10.0 and are having trouble with the v0.11.0 breaking changes, simply updating the version of `go-codec-dagpb` you are using to >=v1.3.2 should resolve the issue.

Any users of libraries within the go-ipfs ecosystem, even if not the go-ipfs package or binary itself, may be affected and should upgrade their dependency on go-codec-dagpb. You can check if your Go module has a dependency on `go-codec-dagpb` by running a command such as `go mod graph | grep go-codec-dagpb` in your module root.

### Workarounds
The best way to workaround this issue is to control exposure to any endpoints that allow for arbitrary IPLD traversals. This primarily includes the HTTP RPC API (https://docs.ipfs.io/reference/http/api ) and the Gateway API.  If you are exposing those APIs, then do so within an environment where only trusted users and applications you control have access to it.  You should be safe as long as your users and applications do not create malformed graphs, which should not happen using standard `go-ipfs` tooling.

If you previously had a more open access environment, then closing off access will only be sufficient if both of the following are true:
* The experimental GraphSync feature is disabled (https://github.com/ipfs/go-ipfs/blob/master/docs/experimental-features.md#graphsync) 
* The only data being accessed is non-malformed data

### References
See also the [go-codec-dagpb security advisory](https://github.com/ipld/go-codec-dagpb/security/advisories/GHSA-g3vv-g2j5-45f2).

### For more information
If you have any questions or comments about this advisory:

* Ask in [IPFS Discord #ipfs-chatter](https://discord.gg/ipfs)
* Open an issue in [go-ipfs](https://github.com/ipld/go-ipfs)

## Which versions are affected by GHSA-mcq2-w56r-5w2w?

4 open source packages ship an affected version, including github.com/ipld/go-ipfs.


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `github.com/ipld/go-ipfs` | Go | All versions | 0.11.1 |
| `github.com/ipld/go-ipfs` | Go | All versions | 0.11.1 |
| `github.com/ipld/go-ipfs` | Go | From 0.12.0 | 0.12.2 |
| `github.com/ipld/go-ipfs` | Go | From 0.12.0 | 0.12.2 |

## How do I fix GHSA-mcq2-w56r-5w2w?

Upgrade github.com/ipld/go-ipfs to a fixed version for your release line: 0.11.1 or 0.12.2.

## Is GHSA-mcq2-w56r-5w2w being exploited?

There is no known exploitation of GHSA-mcq2-w56r-5w2w in the wild and no public exploit code.

## Fix prompt for AI coding agents

```text
Check this codebase for GHSA-mcq2-w56r-5w2w and fix it if it is affected.

What it is: GHSA-mcq2-w56r-5w2w is a denial of service vulnerability in github.com/ipld/go-ipfs, published on 8 Apr 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 GHSA-mcq2-w56r-5w2w in the wild and no public exploit code.

Affected packages and fixed versions:
- github.com/ipld/go-ipfs (Go): affected all versions; fixed in 0.11.1
- github.com/ipld/go-ipfs (Go): affected all versions; fixed in 0.11.1
- github.com/ipld/go-ipfs (Go): affected from 0.12.0; fixed in 0.12.2
- github.com/ipld/go-ipfs (Go): affected from 0.12.0; fixed in 0.12.2

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-mcq2-w56r-5w2w/ (Markdown: https://insights.sbomify.com/GHSA-mcq2-w56r-5w2w/index.md)
```

## Sources

- OSV: https://osv.dev/vulnerability/GHSA-mcq2-w56r-5w2w

---
From sbomify Insights: https://insights.sbomify.com/GHSA-mcq2-w56r-5w2w/
Summaries are generated and may contain mistakes; the official description above is the record.
