# RUSTSEC-2026-0365: Remote DoS through unchecked `IdList` allocation in negentropy

> Remote attackers can crash applications using the negentropy library by sending small malformed messages that trigger excessive memory allocation.

- **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:** 14 Oct 2026

## What is RUSTSEC-2026-0365?

RUSTSEC-2026-0365 is a denial of service vulnerability in negentropy, published on 14 Oct 2026. An attacker can exploit it over the internet without logging in, with no action from the victim.

### Official description

## Summary

The `negentropy` crate is vulnerable to denial-of-service through an unchecked, peer-controlled ID count in reconciliation messages.

With the `std` feature enabled, which is the default configuration, a small malformed message can trigger an enormous memory allocation and terminate the application.

## Details

When processing an `IdList` range, the reconciliation parser uses the peer-provided ID count to reserve memory before checking whether the message contains the corresponding IDs:

```rust
let mut their_elems: HashSet<Id> =
    HashSet::with_capacity(num_ids as usize);
```

An attacker can declare an arbitrarily large count without supplying any IDs. The allocation occurs before the parser reaches the ID-reading loop, which would otherwise reject the truncated message.

With Rust's default allocation-error behavior, a failed allocation aborts the process rather than unwinding. Consequently, `catch_unwind` cannot contain the failure.

Both `reconcile` and `reconcile_with_ids` reach the vulnerable parser.

The patched versions validate the count against the remaining message length before allocating:

```rust
if num_ids > (query.len() / ID_SIZE) as u64 {
    return Err(Error::ParseEndsPrematurely);
}
```

## Impact

An unauthenticated remote attacker can terminate an application that exposes reconciliation to untrusted peers without additional validation.

For example, a Nostr relay that forwards `NEG-OPEN` or `NEG-MSG` reconciliation payloads to the vulnerable parser can be taken down by a single client message. Clients processing messages from malicious relays are also exposed.

This specific vulnerability affects builds with the default `std` feature enabled. Builds without `std` use a `BTreeSet` and do not perform the vulnerable preallocation.

A message-size limit alone does not prevent exploitation because the malicious payload can be only a few bytes long.

## Credit

Discovered and fixed by **Alex Gleason** (<https://github.com/alexgleason>).

## Which versions are affected by RUSTSEC-2026-0365?

1 open source package ship an affected version, including negentropy.


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `negentropy` | crates.io | From 0.2.0 | 0.4.4, 0.5.2 |

## How do I fix RUSTSEC-2026-0365?

Upgrade negentropy to a fixed version for your release line: 0.4.4 or 0.5.2.

## Is RUSTSEC-2026-0365 being exploited?

There is no known exploitation of RUSTSEC-2026-0365 in the wild and no public exploit code.

## Fix prompt for AI coding agents

```text
Check this codebase for RUSTSEC-2026-0365 and fix it if it is affected.

What it is: RUSTSEC-2026-0365 is a denial of service vulnerability in negentropy, published on 14 Oct 2026. An attacker can exploit it over the internet without logging in, with no action from the victim.
Exploitation: There is no known exploitation of RUSTSEC-2026-0365 in the wild and no public exploit code.

Affected packages and fixed versions:
- negentropy (crates.io): affected from 0.2.0; fixed in 0.4.4, 0.5.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/RUSTSEC-2026-0365/ (Markdown: https://insights.sbomify.com/RUSTSEC-2026-0365/index.md)
```

## Sources

- OSV: https://osv.dev/vulnerability/RUSTSEC-2026-0365

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