Skip to content

[rust] Support pbzx-compressed macOS .pkg payloads - #17691

Merged
AutomatedTester merged 1 commit into
trunkfrom
fix-firefox-pbzx-pkg-macos
Jun 19, 2026
Merged

[rust] Support pbzx-compressed macOS .pkg payloads#17691
AutomatedTester merged 1 commit into
trunkfrom
fix-firefox-pbzx-pkg-macos

Conversation

@AutomatedTester

Copy link
Copy Markdown
Member

Description

Selenium Manager fails to install newer Firefox builds on macOS with:

cpio archive error: bad magic value encountered
  3: selenium_manager::files::uncompress_pkg

Root cause

Mozilla changed the Firefox macOS .pkg Payload compression from gzip-cpio to Apple's pbzx (LZMA-block) format, starting on the beta channel (153.0b1). The apple-flat-package crate's payload decoder only sniffs the gzip header — for anything else it passes the bytes through untouched — so the pbzx/LZMA bytes were fed straight into the cpio reader, which rejected them as bad magic.

This was verified end-to-end: the downloaded .pkg is byte-for-byte valid (SHA256 matches Mozilla's published SHA256SUMS); only extraction was broken. The Payload begins with 70 62 7a 78 (pbzx) on 153.0b1 versus 1f 8b (gzip) on 152.0/ESR.

Today this affects the beta channel; once 153 promotes to stable it would break all macOS Firefox installs via Selenium Manager.

Fix

uncompress_pkg now reads the Payload via the XAR reader, detects the pbzx magic, and decodes it (pbzx → xz blocks → cpio) before extraction. gzip and uncompressed payloads are handled exactly as before. No new dependencies (xz2/flate2 were already present).

Verification

  • New unit tests cover stored, xz, multi-chunk, and non-pbzx inputs (bazel test //rust:unit).
  • End-to-end on macOS (arm64):
    • firefox --browser-version beta (153.0b1, pbzx) — now extracts and resolves the browser path. ✅
    • firefox --browser-version 121.0.1 (gzip) — still works (no regression). ✅

Types of changes

  • Bug fix (non-breaking change which fixes an issue)

Checklist

  • I have added tests to cover my changes.
  • All new and existing tests passed.

Newer Firefox macOS packages (starting on the beta channel, 153.0b1) wrap
the cpio Payload in Apple's pbzx (LZMA-block) format instead of gzip. The
apple-flat-package crate only decodes gzip, so it fed the raw pbzx bytes to
the cpio reader and failed with "cpio archive error: bad magic value",
leaving Selenium Manager unable to install affected Firefox builds.

Read the Payload via the XAR reader, detect the pbzx magic, and decode it to
the raw cpio stream before extraction. gzip and uncompressed payloads are
unchanged. Adds unit tests covering stored, xz, multi-chunk, and non-pbzx
inputs.
@selenium-ci selenium-ci added C-rust Rust code is mostly Selenium Manager B-manager Selenium Manager labels Jun 19, 2026
@diemol

diemol commented Jun 19, 2026

Copy link
Copy Markdown
Member

I made this change in the browser update PR. It seems we should be downloading the dmg instead of pkg.

The dmg is what we are actually using in pinned browsers.

Edit: I made means (Claudio and me).

@AutomatedTester

Copy link
Copy Markdown
Member Author

pkg files are better for enterprise environments especially MDM software, I think we may want to revert your change @diemol once this change has landed

@AutomatedTester
AutomatedTester merged commit d770acb into trunk Jun 19, 2026
66 checks passed
@AutomatedTester
AutomatedTester deleted the fix-firefox-pbzx-pkg-macos branch June 19, 2026 09:35
AutomatedTester added a commit that referenced this pull request Jun 22, 2026
The DMG-only workaround was added because PKG extraction failed with a
cpio "bad magic value" error on newer Firefox builds. That root cause was
fixed in #17691 (support for pbzx-compressed macOS .pkg payloads), so the
version-based PKG/DMG selection can be restored.
This was referenced Jul 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

B-manager Selenium Manager C-rust Rust code is mostly Selenium Manager

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants