Summary
scripts/fetch-binaries.ts downloads MediaInfo from mediaarea.net over HTTPS and shells out to it during every scan to extract video metadata. There is no integrity verification (no SHA-256, no signature) on the downloaded binary — only a version-pinned URL. A future mediaarea.net compromise (or a MITM on a corporate proxy that re-signs TLS) would land an attacker-controlled executable in packages/engine/bin/mediainfo, where it then executes with the user's privileges on every scan.
Additionally, the downloaded .zip is written directly to its final name (mediainfo.zip). If the fetch is interrupted, a corrupt zip remains at the final path, which can mislead other tooling. The extracted binary already uses the tmpfile→rename pattern correctly (fetch-binaries.ts:108-118); the zip download should follow the same pattern.
Background
From the 2026-05-17 multi-agent full-repo review. Verified: grep -n "createHash\|sha256\|checksum\|integrity\|verify" scripts/fetch-binaries.ts returns zero hits.
Acceptance criteria
SHA-256 verification
Zip tmpfile→rename
Files affected (likely)
scripts/fetch-binaries.ts — verification + tmpfile pattern
.gitignore — confirm packages/engine/bin/*.partial and *.zip already ignored, or add
- A small unit test of the verifier (place in
scripts/ if a test path exists, otherwise inline in the script's own test file)
Suggested approach
import { createHash } from 'node:crypto';
import { readFileSync } from 'node:fs';
const MEDIAINFO_ZIP_SHA256 = '...'; // capture once; pin
async function verifyZip(path: string): Promise<void> {
const bytes = readFileSync(path);
const actual = createHash('sha256').update(bytes).digest('hex');
if (actual !== MEDIAINFO_ZIP_SHA256) {
throw new Error(`SHA-256 mismatch: expected ${MEDIAINFO_ZIP_SHA256}, got ${actual}`);
}
}
Download to mediainfo.zip.partial, verify, then renameSync to mediainfo.zip.
Out of scope
- GPG-signature verification (overkill for v1; SHA-256 from a pinned constant is the minimum bar).
- Switching to a self-hosted mirror.
- ffprobe (the spec mentions ffprobe as a backup; not currently fetched).
References
- Spec §3.1 — mediainfo as a subprocess dependency
- Code:
scripts/fetch-binaries.ts
- Standards: implicit "supply-chain hygiene" —
standards/dependency-discipline.md covers third-party packages but not bundled binaries; this is the binary-fetch equivalent
Summary
scripts/fetch-binaries.tsdownloadsMediaInfofrommediaarea.netover HTTPS and shells out to it during every scan to extract video metadata. There is no integrity verification (no SHA-256, no signature) on the downloaded binary — only a version-pinned URL. A future mediaarea.net compromise (or a MITM on a corporate proxy that re-signs TLS) would land an attacker-controlled executable inpackages/engine/bin/mediainfo, where it then executes with the user's privileges on every scan.Additionally, the downloaded
.zipis written directly to its final name (mediainfo.zip). If the fetch is interrupted, a corrupt zip remains at the final path, which can mislead other tooling. The extracted binary already uses the tmpfile→rename pattern correctly (fetch-binaries.ts:108-118); the zip download should follow the same pattern.Background
From the 2026-05-17 multi-agent full-repo review. Verified:
grep -n "createHash\|sha256\|checksum\|integrity\|verify" scripts/fetch-binaries.tsreturns zero hits.Acceptance criteria
SHA-256 verification
mediainfo.zipis pinned inscripts/fetch-binaries.tsalongside the URL (sameMEDIAINFO_VERSIONconstant, parallelMEDIAINFO_ZIP_SHA256).createHash('sha256').update(zipBytes).digest('hex')and compares to the pinned value.MEDIAINFO_VERSIONis captured by running the download once and recording the result (note in PR description: "captured 2026-MM-DD by downloading from https://...").Zip tmpfile→rename
mediainfo.zip.partial; only after successful download AND hash verification is it renamed tomediainfo.zip..partialfile, which is.gitignored. Re-runningnpm run fetch-binariescleans it up and re-downloads.Files affected (likely)
scripts/fetch-binaries.ts— verification + tmpfile pattern.gitignore— confirmpackages/engine/bin/*.partialand*.zipalready ignored, or addscripts/if a test path exists, otherwise inline in the script's own test file)Suggested approach
Download to
mediainfo.zip.partial, verify, thenrenameSynctomediainfo.zip.Out of scope
References
scripts/fetch-binaries.tsstandards/dependency-discipline.mdcovers third-party packages but not bundled binaries; this is the binary-fetch equivalent