Skip to content

ci: grant allow-dyld-environment-variables in the macOS signing profile (tebako#1117) - #110

Merged
ronaldtse merged 1 commit into
mainfrom
audit/dyld-entitlement
Nov 25, 2026
Merged

ronaldtse merged 1 commit into
mainfrom
audit/dyld-entitlement

Conversation

@ronaldtse

Copy link
Copy Markdown
Contributor

macOS entitlements: the allow-dyld-environment-variables grant (tebako#1117 — the python cell)

The audit verdict

tebako#1117's per-factory question: does the runtime exe (a) re-exec with DYLD_INSERT_LIBRARIES armed AND (b) need the shim for core IO visibility? For this factory both answers are YES — the shape is tebako-runtime-r#5's exactly:

  • (a) build/resources/tebako_python_main.c (the fs TU) boots the driver in-process, then re-execs the exe with the driver-armed env — DYLD_INSERT_LIBRARIES naming the materialized in-image libtfs_preload.dylib (README's two-incarnation composition).
  • (b) CPython is unpatched (the tamatebako/python zero-patch contract): every interpreter read of the mounted tree — the encodings import, the stdlib — is plain libc IO that only the shim serves.

So the sign profile must carry com.apple.security.cs.allow-dyld-environment-variables, and today it does not.

Why the omission never fired (the issue's "works on darwin-23" cell)

Every python runtime published to date ships unsigned — verified on the published v0.3.5 macos-arm64 exe: flags=0x20002 (adhoc,linker-signed), no TeamIdentifier; APPLE_SIGNING_ENABLED has never been armed in this repo. dyld strips DYLD_INSERT_LIBRARIES only for hardened-runtime targets, so an adhoc exe keeps the insertion on every macOS generation. That — and nothing else — is why the pydata demo ran green on darwin-23 (native extensions reading in-image data). This is the "DYLD not stripped for this profile shape" answer the issue names as fragile: the day the signing gate arms, the same bytes take the hardened runtime and the R#5 class fires on macOS 14. The grant therefore lands now, while the legs still ship unsigned — ahead of the gate.

The evidence (darwin-23 = macOS 14.1.1, 23B81, arm64)

Probe Result
Published v0.2.7 pair (sha256-verified store bytes), TEBAKO_RUNTIME_IMAGE=… exe -c 'import json,zlib,ssl; open(sys.prefix+"/lib/python3.14/json/__init__.py","rb").read()' green — stdlib imports + a 14132-byte libc read of an in-image path (the demo-era shape: unsigned ⇒ insertion honored)
The same-class exe adhoc-signed --options runtime with the CURRENT two-key profile, same probe dies — ModuleNotFoundError: No module named 'encodings' (the stripping, reproduced — python's analog of R's "unable to open the base package")
The same exe re-signed adding ONLY allow-dyld-environment-variables green — stdlib + the libc in-image read served

The change

  • ci/runtime.entitlements gains com.apple.security.cs.allow-dyld-environment-variables with the load-bearing rationale (why the re-exec needs it, why disable-library-validation never covered it, why it lands ahead of the signing gate).
  • ci/macos-sign-notarize-runtime.sh — the embedded-profile check now requires three <true/> values AND greps each key by name (r#6's hardening: no macos-15 runner can police a missing grant at exec time — its dyld tolerates the omission — so the profile is asserted statically, in-leg).
  • .github/workflows/_build-platform.yml — the sign step's comment stops re-spelling the pair (the enumeration lives in the profile, asserted by the script).
  • docs/build-chain.md (new) — the audit's required mechanism record: the shape, the unsigned-shipping explanation, the A/B evidence table, the policing rationale.
  • README.md — the re-exec section names the entitlement plane and points at the record.

A macOS-14 exec canary leg in the publish acceptance (the R factory's publish.yml shape) is the named follow-up — the boot smoke's boot scenario already carries the shim-service probe (stdlib imports off the mount), so the canary is a runner pin, not new probe code.

Verification

  • plutil -lint ci/runtime.entitlements — OK.
  • bash -n ci/macos-sign-notarize-runtime.sh — OK.
  • bundle exec rspec — 95 examples, 0 failures.
  • bundle exec scripts/check_contract.rb — validates.
  • The darwin-23 A/B table above (executed for this audit on the published bytes' class).

Draft — per the ecosystem rule, nothing merges without the owner's explicit go-ahead.

@ronaldtse
ronaldtse marked this pull request as ready for review November 25, 2026 09:12

This branch was previously deployed

1 inactive deployment
windows-signing — 938ee2bd Deployed Nov 25, 2026 by ronaldtse via linux-musl / 3.14.7 / linux-musl-arm64 #249
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