GHSA-2wrx-84qj-4pcg - anacrolix torrent has unbounded recursion in the bencode decoder that causes stack-overflow crash and CPU-exhaustion DoS
## Summary
anacrolix/torrent's bencode decoder (`bencode/`) applies **no limit on the nesting depth** of nested dictionaries and lists. Two distinct denial-of-service mechanisms follow from that single root cause, both reachable from a single crafted `.torrent` file or from metadata obtained from a peer on a magnet-link/v2 download:
1. **Stack-overflow process crash.** `Decoder.readOneValue` recurses once per nesting level with no depth bound. A `.torrent` whose `info` value is a list nested a few million levels deep (โ8 MB file) drives the recursion past the 1 GiB goroutine-stack limit and the process dies with an unrecoverable `fatal error: stack overflow`. 2. **Quadratic CPU exhaustion.** `metainfo.FileTree.UnmarshalBencode` (BitTorrent v2) re-parses each subtree at every level, making parse time grow ~O(nยฒ). A v2 info dict with a ~30,000-level file tree (โ0.2 MB) takes ~66 s to decode; 60,000 levels exceeds 90 s of decode time.
Affected: every application embedding `github.com/anacrolix/torrent` that ingests attacker-supplied metainfo - the CLI tools (`cmd/torrent`, `cmd/torrent2`), any server that opens `.torrent` files, or any client that accepts metadata from a peer for a magnet/v2 download. No depth limit has ever existed in the decoder.
## Vulnerability Details
All file:line references are against the pinned commit `4ad31c5170787215c51c6ddaa54abc06b623c11c`.
### Root cause - no recursion/depth limit in the bencode decoder
`bencode/decode.go` implements three independently unbounded recursive parsers. There is no depth counter and no `MaxDepth`/nesting guard anywhere in `bencode/` or `metainfo/`.
**Defect 1 - `readOneValue` recursion (`bencode/decode.go:546-549`)**
```go
case 'd', 'l':
// read until there is nothing to read
for d.readOneValue() {
} // <- recurses once per nested dict/list level, unbounded
```
`readOneValue` is invoked by `Decoder.parseUnmarshaler` (`bencode/decode.go:591`) whenever a decoded field
MEDIUM
Severity & confidence
Source severitymedium
Platform severitymedium
Confidencemedium
Exploitationunknown
CVSS6.5
Affected
Vendorsgithub
Productsgithub.com/anacrolix/torrent
Reporting sources (1)
GitHub Security Advisories
Timeline & provenance
Published2026-10-30T22:55:09
Last updated2026-11-09T09:35:06
Ingested2026-10-30T22:59:15
FreshnessNEAR-REAL-TIME
Threat typeadvisory
Recommended action
Review the advisory and upgrade affected packages to the first patched version.
Next steps
- Identify affected systems in your environment.
- Apply the vendor patch or mitigation guidance.
- Review logs for indicators described in the advisory.
- Follow the affected vendor/product to track updates.
Confidence explanation
Reported by a single or secondary source; treat as indicative, verify before acting.
Source type: vendor ยท Original: GitHub Security Advisories