Repository navigation
Verify woff - #560
Open
seuninfoo-svg wants to merge 2 commits into
Open
Verify woff#560seuninfoo-svg wants to merge 2 commits into
seuninfoo-svg wants to merge 2 commits into
Conversation
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.
PR: Add WOFF/WOFF2 Magic Byte Verification for Font Assets
Summary
Implements a static repository check that validates committed
.woffand.woff2font files by verifying their magic bytes. This prevents malicious files disguised as fonts (e.g., JavaScript payloads with.woffextension) from being committed to the repository.Motivation
Files named
.woffor.woff2can be used to conceal executable content (JavaScript, shell scripts, etc.). Real font files have recognizable binary signatures (magic bytes) that can be checked without executing or parsing the full file:.woff277 4F 46 32wOF2.woff77 4F 46 46wOFFThis checker reads only the first 4 bytes of each font file—never executing or fully parsing it—and rejects files with mismatched magic bytes.
Changes
New Files
scripts/check-font-magic.mjsfs.openSync/readSync)scripts/check-font-magic.test.mjsModified Files
package.jsonfont:check,font:testscriptsscripts/check-logging.mjsconsolefor CLI output)Acceptance Criteria
All criteria from issue #478 are satisfied:
.woff2files must begin withwOF2magic bytesMAGIC_WOFF2 = [0x77, 0x4F, 0x46, 0x32].wofffiles must begin withwOFFmagic bytesMAGIC_WOFF = [0x77, 0x4F, 0x46, 0x46]path/file.woff2: invalid woff2 magic bytes...+process.exitCode=1pnpm font:check/pnpm font:testfs.openSync+fs.readSyncwith 4-byte bufferUsage
Manual Check
CI Integration
Run Tests
pnpm font:test # 12 tests passingTest Coverage
Test Fixtures (created in temp dirs, not committed)
valid.woff277 4F 46 32 00 01 00 00valid.woff77 4F 46 46 00 01 00 00fake.woff2"this is not a font"fake.woff"also not a font"tiny.woff2"wof"(3 bytes)subdir/nested.woff2subdir/bad.woff2"not a font"subdir/bad.woff2node_modules/pkg/x.woff2.git/objects/x.woffExample Output
Clean Repository
Violations Found
Design Decisions
fs.openSync+fs.readSyncwith a 4-byte buffer; never reads the full filenode_modules,.git,dist,target,artifacts,tmp-bindingsfs,path,url)Files Checked
The scanner recursively checks these directories:
packages/services/apps/scripts/.github/And ignores:
node_modules/dist/target/.git/artifacts/tmp-bindings/Related
check-lockfile-sources.mjs(issue security(ci): reject unreviewed dependency sources in the pnpm lockfile #493)close #478