Repository navigation
iclouddrive: replace plaintext signin with SRP authentication - #9209
Conversation
|
@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. |
|
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:
***@***.***>
|
|
Thanks to @xz-dev for the fix for mainland China, this should work for everyone now. We just need someone to approve it! |
|
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. |
|
Wow ty fr . . I tried every single solution out there online , nothing worked except this one. Once again, thank you so much |
|
@mikegillan is this pr ready for merge? Can you comment on backwards compatibility. Will users have to change their config or reconnect? It appears to be popular with testers so I'd like to try to get it merged. |
|
I had put this comment on the issue and also here. No it is still not working. I then moved it to my termux and then ran the ```rclone-pr9209-android-arm64 config`` I get the error Error: authStart: Get "https://idmsa.apple.com/appleauth/auth/authorize/signin?Authversion......" Maybe some auth headers or the user-agent issue. |
Hello @ncw! Yes, this is ready to merge and by now has been tested pretty extensively. There are still some testers reporting difficulties but I suspect those are environmental or build-related rather than an issue with the PR. Once merged, users who wish to connect to iclouddrive will need to re-run their config (at least for this endpoint) to allow the SRP negotiation to complete and obtain an authorization token from Apple. Thanks! |
|
Built from PR #9234 and also tested commit ea6c891c8a522f35a4b4d31190747ce74f0e0b14. Environment: Windows build and Linux build both tested Observed behavior: SRP authentication succeeds and reaches SRP sign in requires 2FA Important detail: my Apple account does have a trusted phone number configured Relevant logs: DEBUG : iclouddrive: SRP sign in requires 2FA This looks like the SRP step is fixed, but the 2FA/trusted-number handling is still broken or incomplete for my account/session. |
|
@Unbounded6106 thanks for testing! I would suggest to come to #9234 for its testing to not confuse anyone here. |
ncw
left a comment
There was a problem hiding this comment.
This is a very nice fix - thank you @mikegillan
It seems to have settled down now and users seem happy so it is time to merge :-)
I'll just run the CI one last time first.
|
@mikegillan can you fix the lint error and then I'll merge :-) Thank you |
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 <[email protected]>
|
@ncw thank you! I've corrected the linter error, rebased with a clean merge, and force-pushed my commit. Fingers crossed it's all clean now. Thank you for your patience, this is my first FOSS contribution so I was learning as I went. :) |
|
@mikegillan Sending you a PR - your change wasn't working for me without it. I wasn't getting the 2fa code. |
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
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 <[email protected]>
Apple IDs are case-insensitive, but the SRP proof computation (M1) hashes the username client-side. The old plaintext signin let the server normalize the case, but with SRP the client must match. Lowercase the Apple ID before use so mixed-case IDs authenticate correctly. Reported-by: ArturKlauser
|
Hi @mikegillan I just rebased this and squashed the fixes so I can merge as 3 commits. I can either merge things as-is or squash - there is no option to fixup things on the github interface! For next time rebase and prepare in the exact commits you want merged is my preferred workflow. I'll leave you to decide whether you want to include the patch by @artushin - in another PR. I'll just wait for the CI to run to make sure I didn't break anything then I'll merge :-) Thank you so much for doing this - it is great to have the iclouddrive working better. |
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 #8818 (China region support) and PR #9209 (SRP authentication). Signed-off-by: Xiangzhe <[email protected]>
|
Thank you all :-) |
Add read-only iCloud Photos support to the existing iclouddrive backend via `service = photos` config option. Also includes auth improvements on top of #9209's SRP authentication. **Photos features:** - 3-level hierarchy: libraries (Personal + Shared Photo Library) → albums → photos/videos - server-side smart albums (All Photos, Videos, Favorites, Screenshots, Live, Bursts, Panoramas, Slo-mo, Time-lapse, Portrait, Long Exposure, Animated, Hidden, Recently Deleted) - User-created albums and nested album folders - Live Photo `.MOV` companions as first-class entries - Edited photo versions (`-edited` suffix) and RAW alternatives - Duplicate filename dedup for camera counter wrap collisions - Parallel cold listing for large albums - Delta sync via CloudKit `changes/zone` - warm listings near-instant from disk cache - Disk cache (libraries, albums, photos) with atomic writes for crash safety - `ChangeNotify` support for FUSE mounts via `changes/zone` polling - `ListR` support for `--fast-list` and recursive operations - `--metadata` support - width, height, added-time, favorite, hidden - Fresh download URLs per file - no stale URL failures on long copies - FUSE mount documentation with recommended flags **Auth improvements over #9209:** - SMS 2FA fallback for users without trusted Apple devices - Explicit push notification request - fixes iOS/macOS 26.4+ where 409 no longer auto-pushes - Thread safety for concurrent FUSE callers (mutexes on session and client state) - Session endpoint caching - skips ~5s `/validate` round-trip on warm start - `Disconnect` support - clears auth state + disk cache - PCS cookie support for Advanced Data Protection accounts, including trusted-device approval for PCS cookies Built on @coughlanio's Photos PoC (Closes #8734) and @mikegillan's SRP auth (#9209). Fixes #7982 Co-authored-by: Chris Coughlan <[email protected]>
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 <[email protected]>
Add read-only iCloud Photos support to the existing iclouddrive backend via `service = photos` config option. Also includes auth improvements on top of rclone#9209's SRP authentication. **Photos features:** - 3-level hierarchy: libraries (Personal + Shared Photo Library) → albums → photos/videos - server-side smart albums (All Photos, Videos, Favorites, Screenshots, Live, Bursts, Panoramas, Slo-mo, Time-lapse, Portrait, Long Exposure, Animated, Hidden, Recently Deleted) - User-created albums and nested album folders - Live Photo `.MOV` companions as first-class entries - Edited photo versions (`-edited` suffix) and RAW alternatives - Duplicate filename dedup for camera counter wrap collisions - Parallel cold listing for large albums - Delta sync via CloudKit `changes/zone` - warm listings near-instant from disk cache - Disk cache (libraries, albums, photos) with atomic writes for crash safety - `ChangeNotify` support for FUSE mounts via `changes/zone` polling - `ListR` support for `--fast-list` and recursive operations - `--metadata` support - width, height, added-time, favorite, hidden - Fresh download URLs per file - no stale URL failures on long copies - FUSE mount documentation with recommended flags **Auth improvements over rclone#9209:** - SMS 2FA fallback for users without trusted Apple devices - Explicit push notification request - fixes iOS/macOS 26.4+ where 409 no longer auto-pushes - Thread safety for concurrent FUSE callers (mutexes on session and client state) - Session endpoint caching - skips ~5s `/validate` round-trip on warm start - `Disconnect` support - clears auth state + disk cache - PCS cookie support for Advanced Data Protection accounts, including trusted-device approval for PCS cookies Built on @coughlanio's Photos PoC (Closes rclone#8734) and @mikegillan's SRP auth (rclone#9209). Fixes rclone#7982 Co-authored-by: Chris Coughlan <[email protected]>
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