iTranslated by AI

The content below is an AI-generated translation. This is an experimental feature, and may contain errors. View original article
#️⃣

Why Apple IDs Were Locked When Using Fastlane

に公開

Using tools like xcodes and fastlane caused an issue where Apple IDs were being locked.

https://twitter.com/fastlanetools/status/1628788397304123393?s=61&t=-ADi06PN5Q9pEQlpeJDcng

As of March 3rd, when this article is being written, it seems that fastlane and Xcodes.app have resolved this issue.
What exactly was happening?

Looking at fastlane PR #21073, to address this issue, they changed the Apple ID authentication process to use an algorithm called hashcash.
https://github.com/fastlane/fastlane/pull/21073

Due to a sudden change, tools like fastlane accessed Apple IDs without performing the proof-of-work calculations required by Apple. Consequently, Apple likely treated these requests as suspicious and locked the Apple IDs.

By the way, it seems that https://appfigures.com identified the use of hashcash and its specifications.

https://twitter.com/joshdholtz/status/1628994906273337344?s=61&t=nuTXfaVV34n4Mub3qFmsFw

Hashcash is an algorithm developed as an anti-spam measure for webmail. It requires the email sender to consume computer resources to prove to the mail server that the email is not spam.
This prevents low-cost, high-volume request spamming.

Solving Hashcash involves using a hash function to generate a hash value that meets specific conditions (in this case, the value of the X-Apple-HC-Bits returned by Apple).
To generate a hash value that satisfies these conditions, one must repeatedly apply a hash function to random data until the conditions are met.

Looking at the fastlane PR, you can see this process in action.

counter = 0
# Repeat in a loop until successful
loop do
  # ↓ Since date is the current time, a different hc is generated every time
  hc = [
    version, bits, date, challenge, ":#{counter}"
  ].join(":")
  
  # ↓ Calculate the hash of hc; if the prefix matches the given bits, proof is successful
  if Digest::SHA1.digest(hc).unpack1('B*')[0, bits.to_i].to_i == 0
    return hc
  end
  counter += 1
end

https://github.com/fastlane/fastlane/pull/21073/files#diff-431b91c178cba00c3e9fc4c30aa254a6f6f4dab3e0a67f58b05694d5636dbc13R39-R49

Similarly, you can see that the same process is being carried out in Xcodes.app, which is written in Swift.

https://github.com/RobotsAndPencils/XcodesApp/pull/361/files#diff-34cf37ba6020d528a67d853be891e653b6b930b2d9a5bfa1685d38203b3e66bcR48-R79

While using API keys is the recommended method for App Store Connect, many people likely use fastlane's spaceship because it allows for more flexibility with permissions.
Although this issue can be addressed by updating your tools, it's interesting to take a look behind the scenes.
It's surprising how a relatively simple mechanism can be used to prevent spam.

Discussion