Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -618,6 +618,18 @@ curl -so /dev/null -w '%{http_code}\n' -X POST --data-binary t \
app and the exporter send, and opens an issue when one is refused. It would have caught this before
the first report. `python scripts/check_gsa_edge.py` asks from your own connection.

**It did, on 2026-11-20 ([#289](https://github.com/parawanderer/OpenTagViewer/issues/289)), and
the rule was a different one.** The edge began refusing any sign-in whose client info spells the OS
`<macOS;…>`, while the identical request saying `<Mac OS X;…>` — what macOS's own `akd` sends —
got through. The legacy Mac profile said `macOS`. Model, version, build and bundle made no
difference; provisioning and the report fetch accept both. Finding it took a dozen requests with
one field changed at a time (the script's `Probe` shape does this), not a day. Two lessons: **any
field in that header can become the one Apple keys on**, so copy Apple's own spelling of each and
not a plausible one; and **a stored session carries its identity and its password**, so it
re-authenticates under the old value on its own. Fixing the profile alone would have left every
existing user to break at their next PET renewal — `identity.respellRefusedOsName` corrects it on
restore.

**So check the neighbours first.** This project shares an authentication path with AltStore,
SideStore, Macless Haystack, OpenBubbles and every Anisette server, because they all copied it
from the same place. When something that worked yesterday fails for everybody, half an hour
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,13 @@ public class AdiDeviceIdentityTest {
* <p>Reproduced from the constant this replaced. The whole point of {@code LEGACY_MAC} is
* that it did not change, so this string is the specification and the enum is the thing
* being checked.
*
* <p>One deliberate exception: the OS name, {@code macOS} until Apple's edge began refusing
* that spelling at sign-in on 2026-11-20 (#289). It must never go back.
*/
@Test
public void theLegacyMacsClientInfoHasNotMoved() {
assertEquals("<MacBookPro13,2> <macOS;13.1;22C65> <com.apple.AuthKit/1 "
assertEquals("<MacBookPro13,2> <Mac OS X;13.1;22C65> <com.apple.AuthKit/1 "
+ "(com.apple.dt.Xcode/3594.4.19)>",
Hardware.LEGACY_MAC.clientInfo());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,10 +187,19 @@ public enum Hardware {
* it has always been wrong, and changing it now would re-identify every existing
* install to fix a contradiction Apple has evidently never minded. The new profile does
* not have it.
*
* <p><b>Except the OS name, which Apple forced.</b> This said {@code macOS} until
* 2026-11-20, when Apple's edge began refusing every Grand Slam sign-in whose client info
* spells it that way - a 190-byte HTML 503, before a credential is looked at (#289).
* {@code Mac OS X} is what macOS's own {@code akd} sends and is let through; model,
* version, build and bundle made no difference either way. Provisioning and the report
* fetch accept both spellings, so nothing else moved. Stored sessions are respelt on
* restore by {@code identity.respellRefusedOsName}, or they would be refused at their
* next re-authentication.
*/
LEGACY_MAC(
"MacBook Pro 13\"",
"MacBookPro13,2", "macOS", "13.1", "22C65",
"MacBookPro13,2", "Mac OS X", "13.1", "22C65",
"1404.0.5", "22.3.0",
"com.apple.dt.Xcode/3594.4.19") {

Expand Down
31 changes: 31 additions & 0 deletions app/src/main/python/identity.py
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,37 @@ def serialOfSession(asyncAccount: Any) -> str:
return serial


REFUSED_OS_NAMES = {"macOS": "Mac OS X"}
"""
OS names Apple's edge refuses at sign-in, and the spelling it accepts for each.

Since 2026-11-20 every Grand Slam sign-in whose client info says `<macOS;…>` gets a 190-byte
HTML 503, whatever the model, version or bundle, and the same request saying `<Mac OS X;…>` is
let through (#289). Every install on the legacy Mac profile said `macOS`, and a stored session
keeps the identity it was established with - including the password, so FindMy.py
re-authenticates on its own when a PET runs out or a fetch gets a 401. Left alone, every such
session would be refused at that moment and its owner told to sign in again for nothing.
"""


def respellRefusedOsName(accountState: dict) -> dict:
"""
Correct a stored account's OS spelling in place, before FindMy.py restores it.

**An exception to `identityForRestore` keeping everything, and a narrow one.** Model,
version, build, serial and ids stay as they were; only the spelling moves, to the one macOS's
own `akd` uses. Nothing Apple binds a session to is in that string - ADI provisioning and the
report fetch accept either - and the alternative is a session that cannot re-authenticate.
"""
stored = (accountState.get("anisette") or {}).get("identity")
if isinstance(stored, dict) and stored.get("os_name") in REFUSED_OS_NAMES:
before = stored["os_name"]
stored["os_name"] = REFUSED_OS_NAMES[before]
print(f"Stored identity said {before!r}, which Apple now refuses at sign-in; "
f"presenting {stored['os_name']!r} instead (#289)")
return accountState


def identityForRestore(previous: Any) -> dict:
"""
The identity a *restored* account should keep: whatever it already had.
Expand Down
1 change: 1 addition & 0 deletions app/src/main/python/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -836,6 +836,7 @@ def getAccount(
return None

data = json.loads(serializedAccountData)
app_identity.respellRefusedOsName(data)

acc = AppleAccount.from_json(data)
_preferLocalAnisette(acc, localAnisette)
Expand Down
59 changes: 57 additions & 2 deletions app/src/test/python/test_identity.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
# ones Java actually produces is asserted on device, by IdentityBridgeTest.
LEGACY_MAC = {
"model": "MacBookPro13,2",
"os_name": "macOS",
"os_name": "Mac OS X",
"os_version": "13.1",
"os_build": "22C65",
"cfnetwork": "1404.0.5",
Expand Down Expand Up @@ -201,7 +201,7 @@ def test_a_legacy_install_signing_in_again_presents_the_mac_it_provisioned_with(
kwargs = identity.identityForNewSession(bridge)

assert kwargs["identity"] == DeviceIdentity(**LEGACY_MAC)
assert kwargs["identity"].platform == "<MacBookPro13,2> <macOS;13.1;22C65>"
assert kwargs["identity"].platform == "<MacBookPro13,2> <Mac OS X;13.1;22C65>"

def test_the_serial_is_this_installs_even_for_a_legacy_machine_profile(self):
"""
Expand Down Expand Up @@ -565,3 +565,58 @@ def test_a_provider_that_imposed_nothing_writes_nothing(self):

assert "serial" not in stored
assert "identity" not in stored


class TestAStoredMacOsSpellingIsRespelt:
"""
#289: since 2026-11-20 Apple's edge refuses any sign-in whose client info says `<macOS;…>`.

Every legacy-Mac session was stored saying that, with its password, so FindMy.py would
re-authenticate under it the next time a PET ran out - and be refused. The restore is the one
place all of them pass through.
"""

REFUSED = {**LEGACY_MAC, "os_name": "macOS"}

def _restored(self, stored_identity):
from findmy.reports.state import LoginState

imposed = {"identity": DeviceIdentity(**stored_identity)} if stored_identity else {}
account = AppleAccount(RemoteAnisetteProvider(
"https://example.invalid", serial=DRAWN_SERIAL, **imposed,
))
stored = account.to_json()
stored["login"]["state"] = LoginState.LOGGED_IN.value

restored = main.getAccount(json.dumps(stored))
assert restored is not None
return restored._asyncacc._anisette

def test_a_session_stored_as_macos_comes_back_as_mac_os_x(self):
provider = self._restored(self.REFUSED)

assert provider.identity == DeviceIdentity(**LEGACY_MAC)
assert provider.identity.platform == "<MacBookPro13,2> <Mac OS X;13.1;22C65>"

def test_only_the_spelling_moves(self):
"""The serial and every other field are what Apple has the session bound to."""
provider = self._restored(self.REFUSED)

assert provider.serial == DRAWN_SERIAL
assert {k: v for k, v in provider.identity.to_json().items() if k != "os_name"} == {
k: v for k, v in self.REFUSED.items() if k != "os_name"
}

def test_other_identities_are_left_exactly_as_stored(self):
assert self._restored(IPHONE).identity == DeviceIdentity(**IPHONE)
assert self._restored(None).identity == CLIENT_IDENTITY

def test_the_mapping_is_untouched_when_there_is_nothing_to_respell(self):
state = {"anisette": {"type": "aniRemote", "url": "https://example.invalid"}}

assert identity.respellRefusedOsName(json.loads(json.dumps(state))) == state

def test_java_no_longer_hands_a_new_session_the_refused_spelling(self):
# The copy at the top of this file is what Java sends; IdentityBridgeTest pins that on
# device. This pins that the copy was moved with it.
assert LEGACY_MAC["os_name"] not in identity.REFUSED_OS_NAMES
21 changes: 16 additions & 5 deletions scripts/check_gsa_edge.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,11 @@
which is all this checks: with a junk body a request that got through is usually a 404 or a 401
rather than a success, and that is fine.

**The Xcode control.** One probe sends the identifier Apple blocked, and is expected to be
refused. It proves the probe can still see the rule. If it starts getting through, Apple has
lifted or reshaped the block; that is reported but is not a failure.
**The controls.** Two probes send what Apple is known to refuse, and are expected to be refused:
the Xcode identifier (September 2026), and the legacy Mac profile with its OS spelt `macOS`
rather than `Mac OS X` (November 2026, #289 - the profile said `macOS` until then, and only the
spelling differs). They prove the probe can still see each rule. If one starts getting through,
Apple has lifted or reshaped that block; that is reported but is not a failure.

Exit codes: 0 all as expected, 1 one of this project's identities was refused, 2 Apple could
not be reached at all.
Expand Down Expand Up @@ -180,7 +182,10 @@ def sign_in(client_info: str) -> dict[str, str]:
}

found: list[Probe] = []
legacy: Profile | None = None
for profile in profiles:
if profile.name == "LEGACY_MAC":
legacy = profile
identity = DeviceIdentity.from_json(profile.identity_json()) # type: ignore[arg-type]
found.append(Probe(
f"sign-in, app {profile.name}", "POST", GSA,
Expand All @@ -206,6 +211,12 @@ def sign_in(client_info: str) -> dict[str, str]:
"sign-in, Xcode control", "POST", GSA,
sign_in(CLIENT_IDENTITY.client_info(_XCODE_BUNDLE)), REFUSED,
))
if legacy is not None:
spelt = DeviceIdentity.from_json({**legacy.identity_json(), "os_name": "macOS"}) # type: ignore[arg-type]
found.append(Probe(
"sign-in, macOS spelling control", "POST", GSA,
sign_in(spelt.client_info(_AKD_BUNDLE)), REFUSED,
))
return found


Expand Down Expand Up @@ -274,8 +285,8 @@ def run(checks: list[Probe], ask: Callable[[Probe], Answer] = fetch, out=sys.std
refused.append(probe.name)
elif probe.expect == REFUSED and verdict == THROUGH:
print(
f"note {probe.name}: Apple no longer refuses the Xcode identifier. The block this "
"check was written for has been lifted or has changed shape. Not a failure.",
f"note {probe.name}: Apple no longer refuses this. The block it was written "
"for has been lifted or has changed shape. Not a failure.",
file=out,
)

Expand Down
33 changes: 25 additions & 8 deletions scripts/test/test_check_gsa_edge.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def test_the_legacy_profile_is_read_despite_its_escaped_quote():
legacy = next(p for p in edge.read_profiles() if p.name == "LEGACY_MAC")

assert legacy.model == "MacBookPro13,2"
assert (legacy.os_name, legacy.os_version, legacy.os_build) == ("macOS", "13.1", "22C65")
assert (legacy.os_name, legacy.os_version, legacy.os_build) == ("Mac OS X", "13.1", "22C65")


def test_a_constant_the_pattern_cannot_read_fails_loudly(tmp_path):
Expand Down Expand Up @@ -132,7 +132,7 @@ def test_the_control_getting_through_is_news_not_a_failure():
])

assert code == 0
assert "no longer refuses the Xcode identifier" in out
assert "sign-in, Xcode control: Apple no longer refuses this" in out


def test_apple_unreachable_is_its_own_exit_code():
Expand All @@ -150,22 +150,39 @@ def test_apple_unreachable_is_its_own_exit_code():
def test_the_legacy_profile_signs_in_with_what_the_app_sent():
"""
Pinned to the wire, not to this script: the header below is copied from the app's refusal
log on 2026-09-13. If the check ever composes something else, it is probing a request the
app does not make.
log on 2026-09-13, with the OS name respelt `Mac OS X` after Apple began refusing `macOS`
on 2026-11-20 (#289). If the check ever composes something else, it is probing a request
the app does not make.
"""
pytest.importorskip("findmy")
legacy = next(p for p in edge.probes(edge.read_profiles()) if p.name == "sign-in, app LEGACY_MAC")

assert legacy.headers["X-MMe-Client-Info"] == (
"<MacBookPro13,2> <macOS;13.1;22C65> <com.apple.AuthKit/1 (com.apple.akd/1.0)>"
"<MacBookPro13,2> <Mac OS X;13.1;22C65> <com.apple.AuthKit/1 (com.apple.akd/1.0)>"
)
assert legacy.headers["User-Agent"] == "akd/1.0 CFNetwork/978.0.7 Darwin/18.7.0"


def test_only_the_control_names_xcode_on_sign_in():
def test_only_the_controls_send_what_apple_refuses_on_sign_in():
pytest.importorskip("findmy")
sign_ins = [p for p in edge.probes(edge.read_profiles()) if p.name.startswith("sign-in")]

for probe in sign_ins:
names_xcode = "com.apple.dt.Xcode" in probe.headers["X-MMe-Client-Info"]
assert names_xcode == (probe.expect == edge.REFUSED), probe.name
client_info = probe.headers["X-MMe-Client-Info"]
refusable = "com.apple.dt.Xcode" in client_info or "<macOS;" in client_info
assert refusable == (probe.expect == edge.REFUSED), probe.name


def test_the_macos_control_differs_from_the_legacy_profile_only_in_the_os_name():
"""
The control is only evidence about the spelling if the spelling is all that differs.
Otherwise a pass for the app and a refusal for the control could be about anything.
"""
pytest.importorskip("findmy")
found = {p.name: p for p in edge.probes(edge.read_profiles())}
legacy, control = found["sign-in, app LEGACY_MAC"], found["sign-in, macOS spelling control"]

assert control.headers["X-MMe-Client-Info"] == (
legacy.headers["X-MMe-Client-Info"].replace("<Mac OS X;", "<macOS;")
)
assert control.expect == edge.REFUSED