Skip to content

Login failures are unreadable: HTTP status is never checked (Apple 503 on apptokens surfaces as a plist decoding error) #243

Closed

Description

@Robetronica

Summary

xtool auth login in password mode fails with an error that gives no clue what went wrong:

Error: DecodingError.dataCorrupted: Data was corrupted. Debug description: The given data was
not a valid property list.. Underlying error: Error Domain=NSCocoaErrorDomain Code=3840
UserInfo={NSDebugDescription=Encountered unknown tag html on line 1}

Two separate things are going on:

  1. Apple currently answers the apptokens operation with 503 Service Temporarily Unavailable
    as an HTML page.
  2. HTTPClientProtocol.makeRequest never inspects response.status, so that HTML is passed
    straight to PropertyListDecoder and the real status and message are lost.

(2) is the part xtool can fix, and it is why this symptom has been so hard to diagnose — see #232
here and altstoreio/AltStore#1698, which look like the same underlying failure seen through the
same missing check.

Environment

  • xtool 1.18.1 (AppImage), Linux x86_64
  • Password login mode, free (non-paid) Apple ID

What is actually on the wire

I patched makeRequest to log method/URL/status/content-type. The full login is:

[http] GET  .../GsService2/lookup -> 200, 25865 bytes, text/x-xml-plist;charset=UTF-8
[http] POST .../GsService2        -> 200,  1451 bytes, text/x-xml-plist;charset=UTF-8   # init
[http] POST .../GsService2        -> 200, 19261 bytes, text/x-xml-plist;charset=UTF-8   # complete
[http] POST .../GsService2        -> 503,   190 bytes, text/html                        # apptokens
[http] body: <html>
<head><title>503 Service Temporarily Unavailable</title></head>
<body>
<center><h1>503 Service Temporarily Unavailable</h1></center>
<hr><center>Apple</center>
</body>
</html>

SRP authentication and 2FA both succeed and are remembered. Only the final
GrandSlamFetchAppTokensOperation fails. listTeams is never reached, so nothing on the
Developer Services side is involved (confirmed by strace: exactly one TCP connection for the
whole login, to gsa.apple.com).

The 503 is invariant

varied result
network (commercial VPN exit in the US, then a residential European ISP) 503
Apple ID (two different accounts) 503
repeated attempts, hours apart 503, byte-identical responses
X-MMe-Client-Info / User-Agent / X-Xcode-Version (4 variants, below) 503

Client identity variants tried, all reaching apptokens and all getting 503:

variant X-MMe-Client-Info
current xtool <Mac16,1> <Mac OS X;14.3.1;23D60> <com.apple.AuthKit/1 (com.apple.akd/1.0)>
modern akd <Mac16,1> <Mac OS X;15.3.1;24D70> <com.apple.AuthKit/1 (com.apple.akd/1.0)>
Xcode-style (the open // TODO: in DeviceInfo.swift) <Mac16,1> <macOS;15.3.1;24D70> <com.apple.AuthKit/1 (com.apple.dt.Xcode/3594.4.19)>
internally consistent legacy <Mac16,1> <Mac OS X;10.14.6;18G103> <com.apple.AuthKit/1 (com.apple.akd/1.0)>

Apple does read the client string — lookup returned 25865 / 26772 / 26766 / 21311 bytes and
complete 19261 / 23145 / 23145 / 14229 bytes respectively — it just refuses apptokens
regardless. So the 503 looks Apple-side rather than something xtool is sending wrong.

Note that xtool's current identity is internally inconsistent: the client string says macOS
14.3.1 (Darwin 23.x) while userAgent says CFNetwork/978.0.7 Darwin/18.7.0, which is macOS
10.14. That didn't turn out to matter here, but it may be worth tidying.

Suggested fix

In Sources/XKit/HTTPClientProtocol/HTTPClientProtocol.swift, makeRequest returns the body
without ever looking at the status, and every caller decodes it as a plist. Checking the status
there and throwing an error carrying the URL, status and a truncated body turns this:

Error: DecodingError.dataCorrupted: ... Encountered unknown tag html on line 1

into this:

Error: POST https://gsa.apple.com/grandslam/GsService2 failed: HTTP 503 (content-type: text/html)
<html><head><title>503 Service Temporarily Unavailable</title></head>...

I have this working locally and am happy to open a PR if the approach looks right. The one thing
to decide is the blast radius: makeRequest has six call sites, including the SDK and Apple Music
APK downloads, so it would be worth confirming none of them rely on reading a non-2xx body.

Related: 2FA failures are silently swallowed

While tracing this I hit a second symptom worth recording. GrandSlamTrustedDeviceRequest,
GrandSlamSMSAuthRequest and GrandSlamValidateRequest all use no-op decoders
(static func decode(data: Data) throws {}). Combined with the missing status check, a failed
2FA push request is discarded entirely and xtool goes on to prompt:

Code:

for a code that was never sent. A wrong or rejected code is likewise ignored, and the failure only
surfaces later as failedSecondaryAuth or another decoding error. Checking the status in
makeRequest would fix this case too.

Separately, GrandSlamTwoFactorAuthenticateOperation hardcodes let phoneNumberID = "1" with a
// TODO: parse phone number list from o=complete req?, so SMS 2FA always targets whichever
trusted number Apple indexes as 1, without checking the account's actual list.

Activity

  1. am0k161 commented on Sep 4, 2026

    @am0k161

    I'm having the same issue on ubuntu 26.04 today, tested with 1.18 and with 1.17. Before today everything worked fine, now I can't log in in any way.

  2. kabiroberai commented on Sep 4, 2026

    @kabiroberai
    Member

    This is indeed still happening; should be fixed by #244

  3. added a commit that references this issue on Sep 4, 2026
    893cf4f
  4. kabiroberai commented on Sep 4, 2026

    @kabiroberai
    Member

    Released v1.19.0 to fix this. @am0k161 @Robetronica let me know if you still run into the issue after updating.

    Separately, @Robetronica feel free to create a PR to improve error handling in these cases!

  5. Robetronica commented on Sep 5, 2026

    @Robetronica
    ContributorAuthor

    With 1.19.0 login works again, thanks for the fix.
    Opened #246 for the error handling side

  6. am0k161 commented on Sep 5, 2026

    @am0k161

    works for me as well, that was fast. Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions