fix(formats): preserve high bits in remaining magic-byte checks (#2384)
* fix(formats): preserve high bits in remaining magic-byte checks
Node's "ascii" decoder masks the high bit, so byte-for-byte signature
comparisons accepted lookalikes such as CD DA ("MZ" | 0x80) or a
high-bit "bplist00"/"NIBArchive" header. ac57c88ef fixed this for the
shared DOS/MZ reader; apply the same latin1 decoding to the remaining
signature checks: NativeAOT and Windows native loader MZ/PE, binary
plist and NIBArchive detection, and PNG IHDR checks.
Display-name decodes (section and metadata stream names) are unchanged.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
* style(windows): format signature admission regressions
---------
Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Co-authored-by: morluto <76467478+morluto@users.noreply.github.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
morluto
parent
43738bec57
commit
8e6f37e2a0
@@ -143,6 +143,22 @@ describe("packaged Windows native admission", () => {
|
||||
},
|
||||
);
|
||||
|
||||
it.each([
|
||||
{ signature: "MZ", offset: 0 },
|
||||
{ signature: "PE", offset: 64 },
|
||||
])(
|
||||
"rejects digest-valid high-bit $signature lookalikes before loading",
|
||||
({ offset }) => {
|
||||
const value = fixture();
|
||||
value.bytes[offset] = (value.bytes[offset] ?? 0) | 0x80;
|
||||
value.manifest.artifactSha256 = createHash("sha256")
|
||||
.update(value.bytes)
|
||||
.digest("hex");
|
||||
expect(loadWindowsNativeAuthority(value.host).available).toBe(false);
|
||||
expect(value.loads()).toBe(0);
|
||||
},
|
||||
);
|
||||
|
||||
it("rejects a digest-valid artifact for another machine", () => {
|
||||
const value = fixture();
|
||||
value.bytes.writeUInt16LE(0xaa64, 68);
|
||||
|
||||
Reference in New Issue
Block a user