Skip to content

tss: Copy Ap,OSEnvironment from the build identity into AP requests - #14

Merged
nikias merged 1 commit into
libimobiledevice:masterfrom
mpass99:tss-ap-osenvironment
Nov 11, 2026
Merged

nikias merged 1 commit into
libimobiledevice:masterfrom
mpass99:tss-ap-osenvironment

Conversation

@mpass99

@mpass99 mpass99 commented Nov 10, 2026

Copy link
Copy Markdown
Contributor

cloudOS build identities (Private Cloud Compute, e.g. cloudOS 26.5 23F75, every
vresearch101ap identity) carry Ap,OSEnvironment = "0x06". Apple's restore host
sends this tag in the AP TSS request. iBoot reads it back from the ticket and applies
the matching /osenvironments overlay of the device tree; for 6 that is
trusted-darwinos, which sets /chosen/darwinos-security-environment = 6.

libtatsu builds the AP parameters and request from a fixed list of Ap,* tags that
does not include this one. A device restored through idevicerestore therefore gets a
ticket without an OS environment and boots in the default one. On cloudOS that leaves
Restricted Execution Mode off and research cryptexes unmountable (hdi_mount EPERM).

This copies the tag in tss_parameters_add_from_manifest() and
tss_request_add_ap_img4_tags(), next to the other Ap,* tags.
plist_dict_copy_uint() takes the manifest's string ("0x06") through
plist_dict_get_uint() and sends an integer, like the other numeric tags. It changes
nothing for an identity without the tag, which includes every iOS one.

Tested with the same change applied to idevicerestore's AP request (vphone-cli's vendored
copy), restoring a vresearch101ap identity carrying the tag. TSS signed the ticket, and
the restored system booted in trusted darwinOS: AMFI logged its environment-6 path, and a
research cryptex was personalized and mounted. Without the tag the same restore boots in
the default environment. This patch itself has been compiled (clang -fsyntax-only) but
not run.

cloudOS build identities carry Ap,OSEnvironment (0x06, trusted darwinOS).
Apple's restore host sends it in the AP TSS request; iBoot reads the value
back from the ticket and applies the matching /osenvironments overlay of
the device tree. Without it the restored device boots in the default
environment, where cryptexes and Restricted Execution Mode are unavailable.
Identities without the tag (every iOS one) are unaffected.
@nikias
nikias merged commit f3641ce into libimobiledevice:master Nov 11, 2026
4 checks passed
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