Skip to content

feat(box): embed Info.plist in the shipped macOS binaries - #109

Merged
hanaduy merged 1 commit into
mainfrom
feature/macos-info-plist
Oct 15, 2026
Merged

hanaduy merged 1 commit into
mainfrom
feature/macos-info-plist

Conversation

@hanaduy

@hanaduy hanaduy commented Oct 14, 2026

Copy link
Copy Markdown
Contributor

Problem

CD Signer refuses a bare Mach-O executable that carries no embedded Info.plist
with CFBundleIdentifier and CFBundleName. The three shipped macOS binaries
have no such section, so the signing task for the GitHub release cannot start
(P515573077).

Solution

A build.rs in the box and containment crates attaches an Info.plist to each
shipped binary through the darwin -sectcreate __TEXT __info_plist link
argument. All three share com.amazon.strands.box, which iBuild accepted on the
ticket; the sibling helpers only ever run as children of strands-box, so a
distinct public identity buys nothing. The section is macOS-only, and
rustc-link-arg-bin scopes it to the three product binaries, so Linux links
unchanged and the test probes carry no section.

The plist is a template — build.rs substitutes CARGO_PKG_VERSION into
__VERSION__ at build time. The release workflow stamps the version with
cargo set-version, so a hardcoded version would disagree with --version on
every release after 0.1.0.

Testing

Check Result
otool -P on the 3 shipped binaries com.amazon.strands.box on each
otool -P on egress/exit/test-probe/mcp-fetch probes no section
explicit ad-hoc re-sign -> codesign -d Identifier=com.amazon.strands.box on all 3
containment crate bumped to 9.9.9 embedded version tracked to 9.9.9
cargo fmt --check (CI's crate set) pass
cargo clippy --workspace --all-targets --all-features (CI's flags) pass
cargo build --workspace --locked --all-targets --all-features pass

The linker's own ad-hoc signature keeps a per-crate hash as its identifier
(strands_box-d727831dd2ebd7b4); codesign adopts the plist identifier only on
an explicit re-sign, which is what the signing task performs.

Notes

Ported from the retired box-staging repo (fee12345 + 855af89f), as the end
state of both: the first commit gave the helpers sub-identifiers, the second
collapsed them onto the shared one. Linux is unverified locally — only
aarch64-apple-darwin is installed here — but build.rs returns before emitting
any link argument when CARGO_CFG_TARGET_OS != "macos", and CI covers the Linux
leg.

## Problem

CD Signer refuses a bare Mach-O executable that carries no embedded
Info.plist with CFBundleIdentifier and CFBundleName. The three shipped
macOS binaries have no such section, so the signing task for the GitHub
release cannot start.

## Solution

A build.rs in the box and containment crates attaches an Info.plist to
each shipped binary through the darwin `-sectcreate __TEXT __info_plist`
link argument. All three share the identifier `com.amazon.strands.box`,
which iBuild accepted on P515573077; the sibling helpers only ever run as
children of strands-box, so a distinct public identity buys nothing. The
section is macOS-only, and `rustc-link-arg-bin` scopes it to the three
product binaries, so Linux links unchanged and the test probes carry no
section.

The plist is a template: build.rs substitutes CARGO_PKG_VERSION into
__VERSION__ at build time, because the release workflow stamps the version
with `cargo set-version` and a hardcoded version would disagree with
`--version` on every release after 0.1.0.

## Testing

Built release and all-targets on macOS arm64. `otool -P` reads
com.amazon.strands.box back from strands-box, strands-box-sock-alias and
strands-box-contain-trampoline, and reports no section on box-egress-probe,
box-exit-probe, containment-test-probe or box-mcp-fetch-server. An explicit
ad-hoc re-sign makes codesign adopt it: `Identifier=com.amazon.strands.box`
on all three, where the linker's own signature had a per-crate hash.
Bumping the containment crate to 9.9.9 moved the embedded version with it.
cargo fmt and the CI clippy invocation both pass.
Comment thread crates/box/build.rs Resolved
@github-actions

Copy link
Copy Markdown

Assessment: Comment

The change is well-scoped and correct: the -sectcreate link args are limited to the three product binaries, test probes are correctly excluded, Linux links unchanged, no new dependencies, and no frozen interface moves. The templated __VERSION__ substitution matches the release flow's cargo set-version nicely. My main reservation is test coverage, given this repo's stance that behavior claims need a test beside them.

Review Categories
  • Testing: All three behavioral claims are verified by hand (otool -P); none are pinned by the suite. A macOS test (skipping elsewhere) would lock them in. (Important)
  • Maintainability: The embed logic and the shared identifier are duplicated across two build.rs files and three plist templates with no guard against drift. Reasonable given the crate boundary — worth confirming it's deliberate. (Important/question)
  • Maintainability: The product-bin list in build.rs is maintained apart from Cargo.toml's [[bin]] entries; a note would prevent a future binary shipping without the section. (Suggestion)

I also checked the macOS diagnostics tool, which only records the codesign --verify status rather than asserting the identifier, so the new com.amazon.strands.box identity does not regress it. Nice work tracing this back to the signing requirement.

@hanaduy
hanaduy merged commit a201d12 into main Oct 15, 2026
17 checks passed
@hanaduy
hanaduy deleted the feature/macos-info-plist branch October 15, 2026 18:06
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.

2 participants