Skip to content

Free, Open Source, Self-Hosted WhatsApp API Gateway

fix(deps): update music-metadata to 11.16.1

Yudhi Armyndharis33bd25269014
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 9acfefae9..8097c1fc6 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -136,6 +136,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- `handlebars` 4.7.9 to 4.7.10, closing two critical advisories in which a crafted template could inject JavaScript into compiled output. It reaches the root tree only through `ts-jest`, so it is dev-only and nothing that ships changes.
- `vitest` 2.1 to 5 in the JavaScript SDK tree, closing its dev-only advisories, and `typescript` 5.9 to 7. Its unit tests now need Node 22.12+; the published package still supports Node 18.
+- `music-metadata` 11.13.0 to 11.16.1, the parser Baileys uses to read an outgoing audio file's duration. It closes three advisories in which a crafted audio file could abort the process or exhaust memory (GHSA-5gfj-9q3v-qfp3, GHSA-8j4c-6x6g-rq3j, GHSA-f94x-6692-553q).
### Upgrade notes (behavior changes)
diff --git a/package-lock.json b/package-lock.json
index 73d818e9e..d0b5463f9 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -11058,9 +11058,9 @@
}
},
"node_modules/music-metadata": {
- "version": "11.13.0",
- "resolved": "https://registry.npmjs.org/music-metadata/-/music-metadata-11.13.0.tgz",
- "integrity": "sha512-uXRaov9dfjSpQufXIU7sMxVZnh+FilCQv2mXn+K5EJ/decP3dTWrgvPYa5r6MtRbieNSCE708Da4J0u1UGfQIw==",
+ "version": "11.16.1",
+ "resolved": "https://registry.npmjs.org/music-metadata/-/music-metadata-11.16.1.tgz",
+ "integrity": "sha512-uR/mHK6eyfl8h3jVCobF5b38Mfg1IDJMiBxIVbmm5F+G1OXEFcUpQHveO84tJBAqvY93GCRY2R4kDyx7s06Rug==",
"funding": [
{
"type": "github",
@@ -11075,7 +11075,7 @@
"dependencies": {
"@borewit/text-codec": "^0.2.2",
"@tokenizer/token": "^0.3.0",
- "content-type": "^2.0.0",
+ "content-type": "^2.1.0",
"debug": "^4.4.3",
"file-type": "^21.3.4",
"media-typer": "^2.0.0",
@@ -11089,9 +11089,9 @@
}
},
"node_modules/music-metadata/node_modules/content-type": {
- "version": "2.0.0",
- "resolved": "https://registry.npmjs.org/content-type/-/content-type-2.0.0.tgz",
- "integrity": "sha512-j/O/d7GcZCyNl7/hwZAb606rzqkyvaDctLmckbxLzHvFBzTJHuGEdodATcP3yIRoDrLHkIATJuvzbFlp/ki2cQ==",
+ "version": "2.1.0",
+ "resolved": "https://registry.npmjs.org/content-type/-/content-type-2.1.0.tgz",
+ "integrity": "sha512-mj7UPXE0jaqaOsukNZRUEfEi2AcL7C/vwmwcHV0O97eO1E1pxBZuyjlZrx5seTaNBg1U6+o35wpa35Qfcc+7ag==",
"license": "MIT",
"engines": {
"node": ">=18"
diff --git a/package.json b/package.json
index 33919b054..b3756bb8e 100644
--- a/package.json
+++ b/package.json
@@ -41,7 +41,7 @@
"lint": "eslint \"{src,apps,libs,test}/**/*.ts\"",
"lint:fix": "eslint \"{src,apps,libs,test}/**/*.ts\" --fix",
"test": "jest",
- "test:scripts": "node --test scripts/proxy-addr.spec.js scripts/postinstall.spec.js scripts/patch-wwebjs-newsletter-preview.spec.js scripts/patch-wwebjs-status.spec.js scripts/patch-wwebjs-ready-sync.spec.js scripts/patch-wwebjs-participant-arity.spec.js scripts/patch-wwebjs-block.spec.js scripts/patch-wwebjs-group-description.spec.js scripts/patch-wwebjs-media-id.spec.js scripts/patch-wwebjs-send-error.spec.js scripts/patch-baileys-appstate.spec.js scripts/patch-baileys-newsletter-create.spec.js scripts/patch-baileys-pairing.spec.js scripts/baileys-pairing.integration.spec.mjs scripts/dockerfile-patchers.spec.js scripts/smoke-test-docker-proxy.spec.js scripts/check-upstream-surface.spec.mjs scripts/check-sdk-docs.spec.mjs scripts/check-audit.spec.mjs scripts/check-contract-shapes.spec.mjs scripts/check-sdk-coverage.spec.mjs scripts/cli-entrypoint-guard.spec.mjs",
+ "test:scripts": "node --test scripts/proxy-addr.spec.js scripts/music-metadata.spec.js scripts/postinstall.spec.js scripts/patch-wwebjs-newsletter-preview.spec.js scripts/patch-wwebjs-status.spec.js scripts/patch-wwebjs-ready-sync.spec.js scripts/patch-wwebjs-participant-arity.spec.js scripts/patch-wwebjs-block.spec.js scripts/patch-wwebjs-group-description.spec.js scripts/patch-wwebjs-media-id.spec.js scripts/patch-wwebjs-send-error.spec.js scripts/patch-baileys-appstate.spec.js scripts/patch-baileys-newsletter-create.spec.js scripts/patch-baileys-pairing.spec.js scripts/baileys-pairing.integration.spec.mjs scripts/dockerfile-patchers.spec.js scripts/smoke-test-docker-proxy.spec.js scripts/check-upstream-surface.spec.mjs scripts/check-sdk-docs.spec.mjs scripts/check-audit.spec.mjs scripts/check-contract-shapes.spec.mjs scripts/check-sdk-coverage.spec.mjs scripts/cli-entrypoint-guard.spec.mjs",
"test:docs": "jest src/common/changelog-sections.spec.ts src/common/ci-privilege-gate.spec.ts src/common/docs-ci-jobs.spec.ts src/common/docs-coverage-policy.spec.ts src/common/docs-metrics-list.spec.ts src/common/docs-next-version.spec.ts src/common/docs-sdk-rate-limit.spec.ts src/common/openapi/docs-06-contract.spec.ts src/common/test-lane-partition.spec.ts src/config/docs-env-example.spec.ts src/config/openapi-contract.spec.ts src/config/openapi-export-pins.spec.ts src/config/wa-web-version-example-pin.spec.ts src/engine/docs-29-counts.spec.ts src/engine/docs-27-backfill-engine.spec.ts src/engine/engine-inventory-parity.spec.ts src/engine/engine-parity.spec.ts src/engine/inventory-mapping-direction.spec.ts src/engine/adapters/baileys-voice-waveform.spec.ts src/engine/adapters/wwebjs-newsletter-preview.spec.ts src/modules/audit/audit-coverage.spec.ts src/modules/auth/global-route-fence-coverage.spec.ts src/modules/auth/query-session-scope-coverage.spec.ts src/modules/docker/compose-network.spec.ts src/modules/queue/bull-board-mount-coverage.spec.ts src/common/release-gate-parity.spec.ts src/database/migrations/__tests__/migration-drift.spec.ts src/common/docs-governance.spec.ts --testPathIgnorePatterns=/node_modules/",
"test:watch": "jest --watch",
"test:cov": "jest --coverage",
diff --git a/scripts/music-metadata.spec.js b/scripts/music-metadata.spec.js
new file mode 100644
index 000000000..08c34769c
--- /dev/null
+++ b/scripts/music-metadata.spec.js
@@ -0,0 +1,44 @@
+'use strict';
+const test = require('node:test');
+const assert = require('node:assert/strict');
+const { spawnSync } = require('node:child_process');
+const { mkdtempSync, rmSync, writeFileSync } = require('node:fs');
+const { tmpdir } = require('node:os');
+const { join } = require('node:path');
+
+// Baileys reads the duration of an outgoing audio file with music-metadata's parseFile. In 11.13.0 an
+// EBML element declaring a 32 GiB length made that call abort the whole process on a native assertion
+// instead of throwing, so one crafted file stopped every session. The parse runs in a child so a
+// regression kills the child, not the test runner, and the exit signal can be asserted.
+const OVERSIZED_WEBM = Buffer.from(
+ [
+ '1a45dfa3874282847765626d', // EBML header, DocType "webm"
+ '1853806701ffffffffffffff', // Segment, unknown size
+ '1549a96601ffffffffffffff', // Info, unknown size
+ '7ba9', // Title leaf ...
+ '0100000800000000', // ... declaring 32 GiB
+ '41', // one byte of content
+ ].join(''),
+ 'hex',
+);
+
+test('a WebM leaf that declares 32 GiB is rejected by music-metadata, not fatal to the process', () => {
+ const dir = mkdtempSync(join(tmpdir(), 'openwa-mm-'));
+ try {
+ const file = join(dir, 'oversized.webm');
+ writeFileSync(file, OVERSIZED_WEBM);
+ const child = spawnSync(
+ process.execPath,
+ [
+ '-e',
+ "import('music-metadata').then(mm => mm.parseFile(process.argv[1], { duration: true })).then(() => process.exit(0), () => process.exit(7))",
+ file,
+ ],
+ { cwd: join(__dirname, '..'), encoding: 'utf8' },
+ );
+ assert.equal(child.signal, null, `the parser killed its process with ${child.signal}: ${child.stderr}`);
+ assert.ok([0, 7].includes(child.status), `unexpected exit ${child.status}: ${child.stderr}`);
+ } finally {
+ rmSync(dir, { recursive: true, force: true });
+ }
+});