Skip to content

stabilize: pin zip-modified-time to UTC - #2034

Open
0z5a wants to merge 1 commit into
google:mainfrom
0z5a:fix/zip-modified-time-utc
Open

0z5a wants to merge 1 commit into
google:mainfrom
0z5a:fix/zip-modified-time-utc

Conversation

@0z5a

@0z5a 0z5a commented Nov 16, 2026

Copy link
Copy Markdown

StableZipModifiedTime set Modified to time.UnixMilli(0), which is in the host's local zone. zip.Writer.CreateHeader encodes the MS-DOS date and time in the location of Modified without converting to UTC. As a result the stabilized bytes of every wheel, egg and jar depended on TZ. An attested stabilized/<artifact> digest could only be reproduced with cmd/stabilize on a UTC host.

This change pins the value to UTC. Output on a UTC host is byte-identical to before, so digests already recorded in attestations stay the same. For example, with the one-line change applied at the attested serviceSource refs, the published stabilized digests for six 1.17.0 (b06155c5...) and absl-py 2.0.0 (21a8a58d...) reproduce under TZ set to UTC, Europe/Berlin, America/New_York and Asia/Kolkata. Before the change they only reproduce under UTC.

Tar and gzip stabilizers are not affected since those formats store Unix seconds.

Testing:

  • New TestStabilizeZipLocalTimeZone stabilizes the same zip with time.Local set to UTC, UTC+9 and UTC-5 and compares the bytes with cmp.Diff. It fails on main for the two non-UTC cases and passes with the fix.
  • go test ./pkg/... ./internal/... and go run ./ci check pass.
  • Timing of StabilizeZip with all zip stabilizers on the absl-py 2.0.0 wheel (200 iterations per run, 15 runs each, main and this change alternating): median 3070.4 µs on main and 3103.8 µs with this change.

This change was drafted with Claude Code (claude-opus-5-5); the test results above are from the runs described.

zip.Writer.CreateHeader encodes the MS-DOS date and time fields in the
location of Modified without converting to UTC. time.UnixMilli(0) is in
the host's local zone, so the stabilized bytes of every wheel, egg and
jar depended on TZ and attested stabilized digests only reproduced on a
UTC host. Output on a UTC host is unchanged.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant