fix(bridge): patch stagelinq file-type CVE (#34/#35) via magic-number shim - #577
Draft
thewrz wants to merge 1 commit into
Draft
fix(bridge): patch stagelinq file-type CVE (#34/#35) via magic-number shim#577thewrz wants to merge 1 commit into
thewrz wants to merge 1 commit into
Conversation
… shim Dependabot alerts #34/#35 (file-type ASF parser DoS) remain open because stagelinq@3.3.1 (latest) still declares file-type@^16.5.3. Patched file-type@21.3.1+ is ESM-only and renames the API, making a simple resolution override impossible. This PR takes the patch-package route: - Replaces FileType.fromBuffer() calls in stagelinq/dist/network/NetworkDevice.js with a synchronous 16-byte magic-number sniff (JPEG FF D8 FF, PNG 89 50 4E 47, GIF 47 49 46 38, WebP RIFF....WEBP), eliminating all runtime use of file-type. - file-type remains installed on disk as a stagelinq dep but is never loaded, closing the attack surface. - Adds patch-package devDependency + postinstall hook to both bridge/ and bridge-app/. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01G3xt1szrKvCLjvGWer4puz
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Comment |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
Dependabot alerts #34 and #35 (file-type ASF parser DoS) have been open since May 2026. They were deferred because:
bridge/andbridge-app/pullfile-type@16.5.4transitively viastagelinq@3.0.4stagelinqis CJS and callsFileType.fromBuffer(albumArt)innode_modules/stagelinq/dist/network/NetworkDevice.jsfile-type@21.3.1+is ESM-only and renames the API (fromBuffer→fileTypeFromBuffer), so a resolution override alone breaks stagelinq at runtimeInvestigation result (2026-08-01):
stagelinq@3.3.1is the latest release (latest on npm, confirmed vianpm view stagelinq versions). It still declaresfile-type: ^16.5.3— the upstream library is unpatched. Path 2 (version bump) is not actionable; this PR takes Path 3 (patch-package shim).What
bridge/patches/stagelinq+3.0.4.patchandbridge-app/patches/stagelinq+3.0.4.patchReplaces both
FileType.fromBuffer()calls innode_modules/stagelinq/dist/network/NetworkDevice.jswith a synchronous 16-byte magic-number sniff:FF D8 FF89 50 4E 4747 49 46 3852 49 46 46…57 45 42 50(bytes 0–3 + 8–11)Returns
{ ext, mime }matching the original FileType shape (only.extis consumed by the caller).The
require("file-type")import is removed from the patched file, sofile-typeis never loaded at runtime — eliminating the CVE attack surface. The package remains on disk as a stagelinq npm dep but is inert.Other changes:
patch-package@^8.0.1added as devDependency in bothbridge/andbridge-app/"postinstall": "patch-package"wired in bothpackage.jsonscriptspackage-lock.jsonfiles updated (npm install --package-lock-only)Dependency tree note: Removing
file-typefrom the resolved tree entirely would require either an ESM-compatible stagelinq release or a local npm stub. Since the runtime call is gone, the on-disk presence is inert and a stub is deferred until stagelinq upgrades.Testing
bridge/:npx vitest run— 351 passed, 1 pre-existing failure (serato-plugin › rescans after 5 consecutive read errors, timing flake confirmed present onmainbefore this branch)npx tsc --noEmitclean onbridge/bridge-app/: install + test suite (Electron; skip in CI, verify locally)bridge/and confirmpatch-packageapplies the patch cleanly; exercise album art path in a live StageLinQ session🤖 Co-authored by Claude. Closes #34, Closes #35
Generated by Claude Code