iclouddrive: replace plaintext signin with SRP authentication#9209
iclouddrive: replace plaintext signin with SRP authentication#9209mikegillan wants to merge 7 commits intorclone:masterfrom
Conversation
Apple deprecated the legacy /appleauth/auth/signin endpoint and now blocks it with 503 responses. Replace it with Apple's SRP-6a variant (federate, signin/init, signin/complete) which never transmits the password. The 2FA and trust token flow remains unchanged.
Apple has deprecated the legacy /appleauth/auth/signin endpoint and now blocks it, causing "Invalid Session Token" errors for all users when their trust token expires. The browser login flow now requires SRP (Secure Remote Password), a cryptographic handshake that never transmits the password. Replace Session.SignIn() with a multi-step SRP-6a flow: 1. authStart - initialize session at /authorize/signin 2. authFederate - submit account name to /federate 3. authSRPInit - exchange client public value for salt/B at /signin/init 4. authSRPComplete - send M1/M2 proofs to /signin/complete The SRP implementation uses the RFC 5054 2048-bit group with SHA-256 and Apple's NoUserNameInX variant. Password derivation supports both s2k and s2k_fo protocols via SHA-256 + PBKDF2. The 2FA and trust token flow is unchanged. Auth headers for all idmsa.apple.com requests now include X-Apple-Auth-Attributes, X-Apple-Frame-Id, and use Origin/Referer of https://idmsa.apple.com. Fixes rclone#8587
|
@mikegillan thanks for fixing this. I just ran the CI - looks like there are some lint things to fix. I gave it a quick review and it looks great. It looks like it has had some testing from users - do you know how many people have tried the new code? |
I don't know but there have been at least two people in the the issue chat reporting that it worked for them. I think most users would be waiting for a nightly build to test it out since they might not have the ability to build locally. Is it possible to give a temp build to users who have indicated interest in the issue? This is my first time contributing to a public project like this (I've only ever done corporate development) so please forgive me if I'm suggesting something stupid here. |
|
I've corrected the formatting on the imports, which should clear the linter errors. |
|
I had to build the Windows version to generate the config file. On the Linux amd64 version, when I tried to configure iCloud, I was still getting the “Invalid Session Token” error. In the config file created on Linux, the “cookies” and “trust_token” fields were not being populated. By creating the config file on Windows and importing it into Linux, everything works without any issues. |
|
Hi @ncw I see there's a build issue with Windows that doesn't look related to any of my changes. Is there anything else I can do to get this ready for merge? Over on the issue page there have been a few people asking how they can get their hands on it, so now I feel a responsibility to see this through. Please let me know if there's anything I can do to help. Thanks! |
|
Hello, To authenticate use you Apple-ID password. App password do not work. Thanks, |
|
Sidenote: |
|
Compiled this PR tonight, it's working great. Effortless connection, Apple couldn't have made it easier. Mounted a folder of notes, no issues either way. Appreciate the hard work, both the pr and rclone project! |
Did you run across the cosmetic issue that it authenticate twice? From what I see the code first authetificate and then run it again for testing access. |
|
Hi All Great to hear this is working. I tried with my own apple id and password and get a 400. Would love to know the process to set it up ? I tried ANd I get this error: |
Whats your output of |
|
Hello. Thank you to @mikegillan for this PR. I am also on Apple Silicon and followed the build steps laid out by @zirkuswurstikus . I can confirm this has worked for me as well. |
This fixes China mainland iCloud authentication by deriving the Origin and Referer headers from authEndpoint instead of hardcoding idmsa.apple.com. Fixes compatibility with PR rclone#8818 (China region support) and PR rclone#9209 (SRP authentication). Signed-off-by: Xiangzhe <xiangzhedev@gmail.com>
|
Nice job, I add more function for that to let it work with #8818 If it's looks fine for you , please merge it, thank you @mikegillan |
|
Just compiled this PR on Apple Silicon (M2 Air), mounted a directory and read a file without issues. Thanks, @mikegillan for this PR and all maintainers for this project. |
|
Hi all , The error is same as before: Error: HTTP error 400 (400 Bad Request) returned body: {"success":false,"error":"Invalid Session Token"} Environment:
Observations:
Hypothesis: Workaround: Browser-based cookie extraction via icloud_cookie_extractor.sh (see #8587). |
|
@harijay according to you post you are using a 1.74-BETA. Do you follow the provided instruction to build rclone? Run this and paste output |
|
Thanks @zirkuswurstikus . I didnt notice that AI pulled from beta branch instead of the PR. It is all working now . Was super thrilled when the 2FA popped up on my phone. I had been trying to get this functionality for months now. You all rock!! Hari Here is the CLAUDE message Update: Works on Linux when built directly from this PR branch After being prompted by @zirkuswurstikus to build from the PR branch rather than using the beta release, I can confirm SRP auth works on Linux. Build used:
Built with: Key finding: You must use your real Apple ID password, not an app-specific password. The SRP handshake requires the real password for the cryptographic exchange. Previous failures The interactive rclone config flow correctly prompted for the 2FA code sent to my phone, completed the SRP handshake, and stored session cookies. rclone lsd successfully listed my
|
|
This is great news, thank you for the update @harijay and thank you for
your sharp eye @zirkuswurstikus!
…On Wed, Mar 4, 2026 at 15:22 Hari Jayaram ***@***.***> wrote:
*harijay* left a comment (rclone/rclone#9209)
<#9209 (comment)>
Thanks @zirkuswurstikus <https://github.com/zirkuswurstikus> . I didnt
notice that AI pulled from beta branch instead of the PR. It is all working
now . Was super thrilled when the 2FA popped up on my phone. I had been
trying to get this functionality for months now.
You all rock!!
Hari
Here is the CLAUDE message
Update: Works on Linux when built directly from this PR branch
After being prompted by @zirkuswurstikus
<https://github.com/zirkuswurstikus> to build from the PR branch rather
than using the beta release, I can confirm SRP auth works on Linux.
Build used:
rclone v1.74.0-DEV
- os/version: ubuntu 24.04 (64 bit)
- os/kernel: 6.17.0-14-generic (x86_64)
- go/version: go1.25.0
Built with:
git fetch origin pull/9209/head:pr-9209
git checkout pr-9209
GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -trimpath -ldflags='-s -w'
-o build/rclone-pr9209-linux-amd64 ./
Key finding: You must use your real Apple ID password, not an app-specific
password. The SRP handshake requires the real password for the
cryptographic exchange. Previous failures
(including my earlier report of authSRPComplete: sign in failed: 401) were
caused by using an app-specific password via rclone config create
non-interactively.
The interactive rclone config flow correctly prompted for the 2FA code
sent to my phone, completed the SRP handshake, and stored session cookies.
rclone lsd successfully listed my
iCloud Drive.
@harijay <https://github.com/harijay> according to you post you are using
a 1.74-BETA. Do you follow the provided instruction to build rclone?
Run this and paste output
mkdir -p /tmp/rclone
cd /tmp/rclone
git clone https://github.com/rclone/rclone.git .
git fetch origin pull/9209/head:pr-9209
git checkout pr-9209
GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -trimpath -ldflags='-s -w' -o build/rclone-pr9209-linux-amd64 ./
rclone version
—
Reply to this email directly, view it on GitHub
<#9209 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAH2S6MNO44VAJ6NJKX54HD4PCGBLAVCNFSM6AAAAACV5IWPLKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHM2DAMBQGA2TKNJQGE>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
Refactor SRP auth headers to use dynamic origin
|
Thanks to @xz-dev for the fix for mainland China, this should work for everyone now. We just need someone to approve it! |
Add read-only iCloud Photos support via `service = photos` config. Lists photo libraries (Personal + Shared), albums (11 smart + user), and photos/videos. Downloads via CloudKit URLs. Based on @coughlanio's PoC (rclone#8734). SRP auth from @mikegillan's rclone#9209. Photos changes from rclone#8734: - Fix Storable() (was false, broke transfers) - Fix List() dir entry paths (missing parent prefix) - Fix Open(): fshttp.NewClient, shouldRetry, FixRangeOption - Fix SetModTime: fs.ErrorCantSetModTime - Add ctx propagation, sync.Mutex, photo name cache - Add Root() encoding, stable timestamps, DirCacheFlush, ErrorIsFile - Add compile-time interface checks - Add batched album count queries SRP changes from rclone#9209: - Replace deprecated /signin with SRP-6a protocol - Add SRP crypto (RFC 5054 2048-bit, SHA-256) - Update auth headers for idmsa.apple.com Fixes rclone#7982
|
This worked for me as well. Thank you to all who worked on it! OS: Ubuntu 22.04 (64 bit) |
|
@JoshPaterson would you mind to also look at #8734? Should hopefully add photos support! |
|
I am receiving two different types of errors for files that are in folders that were shared to me by someone else. Files that I shared from my account to others don't have errors.
Please let me know if you'd like more information about these errors or the files that caused them. |
Summary
/appleauth/auth/signinplaintext endpoint with Apple's SRP-6a (Secure Remote Password) protocolauthStart→authFederate→signin/init→signin/completes2kands2k_fopassword derivation protocolsApple deprecated the old signin endpoint and now blocks it, causing "Invalid Session Token" errors for all users once their trust token expires. This affects everyone — the issue has 119 comments and counting.
Fixes #8587
Test plan
go build ./backend/iclouddrive/...compilesgo vet ./backend/iclouddrive/...passes (no new warnings)go test ./backend/iclouddrive/...— existing tests passapi/srp_test.go— all passrclone config→ SRP handshake completes → 2FA prompt → trust token savedrclone lsd iCloudDrive:lists directories after authChecklist