Possible: Windows bsdtar text-mode stdout may corrupt binary extraction in check-package.mjs
Summary
Filing this as an unverified hypothesis rather than a confirmed bug, because I do not have a Windows host to test on. It follows directly from the premise of #32 and would affect package verification rather than a scan.
#32 established that Windows bsdtar writes its listing to stdout in text mode, which is what turns LF into CRLF and broke check-package.mjs. If stdout is in text mode for that invocation, the same translation plausibly applies to -xO binary extraction. If it does, check-package.mjs receives LF→CRLF-translated bytes for the artifacts it verifies byte-exactly, and two checks would fail or, worse, silently compare translated content:
- the Brotli trailing-data check
- the PNG SHA-256 comparison
Environment
@openai/codex-security0.1.5, currentmainatea19f24- Reported condition would be Windows with the bundled
bsdtar(C:\Windows\System32\tar.exe), invoked from PowerShell orcmd
Why CI does not show it
The Inspect package step in .github/workflows/node-ci.yml sets shell: bash, so on windows-latest tar resolves to MSYS2 GNU tar, which writes LF. That is also the likely reason #32's reporter hit the listing bug from PowerShell while windows-latest CI stayed green — CI never exercises the bsdtar path at all.
How to check
On a Windows host, from PowerShell rather than Git Bash:
tar -xOf <tarball> package/dist/<some .br file> | Format-Hex | Select-Object -First 4
and compare the byte count and trailing bytes against the same extraction under Git Bash. A difference of one byte per LF confirms it.
Suggested direction
If confirmed, the fix is to stop relying on inherited stdout mode for binary extraction — extract to a file and read it back, or invoke the extraction in a way that guarantees binary mode — and to add a CI leg that runs check:package under PowerShell so the bsdtar path is covered at all.
Related: #32 fixed the listing half of this; PR #217 is the corresponding change. This issue is only about binary extraction and is deliberately kept separate.
I have a Windows host, so I ran this down. The hypothesis does not hold: -xO binary extraction is byte-exact. The #32 premise is real, but the translation is confined to the listing output and does not reach entry content.
Method
Rather than piping through PowerShell (which would add its own encoding layer and prove nothing about the script), I replicated check-package.mjs's own mechanism — spawnSync(tar, ["--ignore-zeros", ...args], { maxBuffer }) with the default buffer encoding — and compared what -xOf returns on stdout against the authoritative bytes from -xf written straight to disk.
@openai/codex-security0.1.5 tarball straight from npm (npm pack, 997,638 bytes)- Windows 11,
C:\Windows\System32\tar.exe= bsdtar 3.8.4 / libarchive 3.8.4 - Node 20.18.1
Results
| Member | -xf → disk |
-xOf → stdout |
Verdict |
|---|---|---|---|
package/_bundled_plugin/mcp/mcp-app.html.br |
115,260 bytes · d10d4d0c…e2b5 |
115,260 bytes · d10d4d0c…e2b5 |
identical |
package/_bundled_plugin/assets/logo.png |
99,567 bytes · 9b9c2b09…0b3a |
99,567 bytes · 9b9c2b09…0b3a |
identical |
The .br payload also decompresses cleanly from the stdout bytes (brotliDecompressSync → 552,932 bytes), so the Brotli trailing-data check and the PNG SHA-256 comparison are both safe on this path.
The contrast that explains it
Same binary, same pipe, two different output paths:
LISTING (-tzf) : CRLF line ends = 179 | bare LF = 0 <- #32's premise, reproduced
BINARY (-xOf) : 115,260 bytes | 0x0A bytes = 459, of which only 4 follow a 0x0D
So bsdtar really is emitting CRLF for its listing — even through a pipe, not just a console — while entry content passes through untranslated. Had translation applied to -xOf, the payload would have come back as 115,719 bytes (115,260 + 459); it came back as 115,260.
That also matches the #32 symptom precisely: the listing is text written through the CRT's text-mode path, whereas extracted entry content is written as binary.
Caveats
- Tested with stdout as a pipe, which is what
spawnSyncgives. I did not test with stdout attached to a console — thoughcheck-package.mjsalways pipes, so that case can't affect it. - Single bsdtar build (3.8.4). If you want the same probe run against an older
System32tar, I'm happy to. - I checked only the two members the script verifies byte-exactly; nothing else in the tarball.
Given the above I'd suggest closing this as not-a-bug unless someone can produce a bsdtar build that behaves differently. I don't think a regression guard is worth adding for behaviour that isn't broken, but say the word if you'd prefer one and I'll put up a focused PR.
Thanks for running this properly — replicating spawnSync with the buffer encoding rather than piping through PowerShell is exactly the right call, and it's what makes the result conclusive. That's the script's real mechanism: check-package.mjs declares tar(args, encoding = "buffer") and every byte-exact call site (package.json, the Brotli payloads, the PNG hash) takes the default, so your probe and the script are on the same path.
Byte-identical output on both members, plus a clean brotliDecompressSync, settles it. The 115,260 vs 115,719 arithmetic is a nice touch — it rules out translation rather than just failing to observe it.
Closing this as not-a-bug. I filed it as an unverified hypothesis precisely because I had no Windows host, and you've answered it. Agreed on skipping the regression guard: a test that pins behaviour libarchive never had is upkeep with no failure mode behind it.
One thing worth carrying forward: your listing numbers (179 CRLF, 0 bare LF, through a pipe) reproduce #32's premise on bsdtar 3.8.4 — two minor versions past the 3.5.2 in the original report. That half of #32 is still unfixed on main: scripts/check-package.mjs still runs /^[^d-]/mu.test(listing), and with the m flag ^ matches between the \r and the \n, so the \n is read as an entry's first character and a valid tarball is rejected. #217 fixes it and is still open. I've linked your measurement there — an independent confirmation on a current bsdtar is more useful than my secondhand reading of #32.
Thanks for the thorough close-out - glad it settled cleanly.