# GHSA-f2gr-7299-487h: DOS and excessive memory usage when passing untrusted user input to to dag import

> Malformed CAR files cause crashes or memory exhaustion in go-ipfs nodes when imported via untrusted input, requiring dependency 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:** 6 Jul 2022

## What is GHSA-f2gr-7299-487h?

GHSA-f2gr-7299-487h is a denial of service vulnerability in github.com/ipfs/go-ipfs, published on 6 Jul 2022. An attacker can exploit it over the internet without logging in, with no action from the victim.

### Official description

### Impact
go-ipfs nodes crash when trying to import certain malformed CAR files due to an issue in the go-car dependency. This impacts nodes running `ipfs dag import` on untrusted user inputs, for example, pinning services with a car ingest endpoint.
This include the corresponding [HTTP RPC API `v0/dag/import`](https://docs.ipfs.io/reference/http/api/#api-v0-dag-import) endpoint.

An attacker controlling the car file passed in can also make the node allocate arbitrary sized buffers creating memory exhaustion attacks.

### Patches
0.13.1, 0.14 and later.

#### Forks
For those running on forked versions of go-ipfs, simply updating the version of `github.com/ipld/go-car/v2` you are using to >= v2.4.0 should resolve the issue.

#### Libraries consumers
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-car.

You can check if your Go module has a dependency on go-car by running a command such as `go mod graph | grep go-car`  in your module root.

Note: if you are using other libraries, some parts of go-car (`github.com/ipld/go-car/v2/index/...`) have not fully been fixed yet.  Please see [go-car's security advisory](https://github.com/ipld/go-car/security/advisories/GHSA-9x4h-8wgm-8xfg) for more information.  go-ipfs do not make use of this code.

### Workarounds
The best way to work around this is to control exposure to the [HTTP RPC API endpoint for CAR imports](https://docs.ipfs.io/reference/http/api/#api-v0-dag-import) to only work with trusted data.

You can also validate that the car will not crash go-ipfs by running `car verify` on it first (`go install github.com/ipld/go-car/cmd/car@latest`).

### References
See also the [go-car security advisory](https://github.com/ipld/go-car/security/advisories/GHSA-9x4h-8wgm-8xfg).

### For more information
If you have any questions or comments about this advisory:
1. Ask in the [IPFS Discourse](discuss.ipfs.io/)
1. Ask in the [IPFS Discord #ipld-chatter](https://discord.gg/ipfs)
1. Open an issue in [go-ipfs](https://github.com/ipfs/go-ipfs)

## Which versions are affected by GHSA-f2gr-7299-487h?

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


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `github.com/ipfs/go-ipfs` | Go | From 0.5.0 | 0.13.1 |
| `github.com/ipfs/go-ipfs` | Go | From 0.5.0 | 0.13.1 |

## How do I fix GHSA-f2gr-7299-487h?

Upgrade github.com/ipfs/go-ipfs to 0.13.1 or later.

## Is GHSA-f2gr-7299-487h being exploited?

There is no known exploitation of GHSA-f2gr-7299-487h in the wild and no public exploit code.

## Fix prompt for AI coding agents

```text
Check this codebase for GHSA-f2gr-7299-487h and fix it if it is affected.

What it is: GHSA-f2gr-7299-487h is a denial of service vulnerability in github.com/ipfs/go-ipfs, published on 6 Jul 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-f2gr-7299-487h in the wild and no public exploit code.

Affected packages and fixed versions:
- github.com/ipfs/go-ipfs (Go): affected from 0.5.0; fixed in 0.13.1
- github.com/ipfs/go-ipfs (Go): affected from 0.5.0; fixed in 0.13.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/GHSA-f2gr-7299-487h/ (Markdown: https://insights.sbomify.com/GHSA-f2gr-7299-487h/index.md)
```

## Sources

- OSV: https://osv.dev/vulnerability/GHSA-f2gr-7299-487h

---
From sbomify Insights: https://insights.sbomify.com/GHSA-f2gr-7299-487h/
Summaries are generated and may contain mistakes; the official description above is the record.
