Repository navigation
Conversation
This is a prerequisite to compare the browser's IP with the client's IP to detect phishing attacks. Signed-off-by: Florentin Putz <dev@fputz.net> Assisted-by: Codex:gpt-6.1-sol
Previously, we only supported accepting requests. But users might want to reject requests. Make declining invalidate the pending request. Prevent competing approvals or cancellations from overwriting the result. Signed-off-by: Florentin Putz <dev@fputz.net> Assisted-by: Codex:gpt-6.1-sol
1d3c720 to
6307e71
Compare
|
@susnux I noticed that there were two lint errors due to unused imports. I have fixed them, hopefully the checks pass now! |
susnux
left a comment
There was a problem hiding this comment.
Looks really great overall, but would need some adjustments to the PlayWright tests.
6307e71 to
740dfc1
Compare
I have now fixed the PlayWright tests that previously failed, so hopefully it should work now. |
skjnldsv
left a comment
There was a problem hiding this comment.
Some comments, overall really great!!
| $browserIp = $this->request->getRemoteAddress(); | ||
| $sameIp = null; | ||
| if ($clientIp !== null && Address::isValid($clientIp) && Address::isValid($browserIp)) { | ||
| $sameIp = (string)new Address($clientIp) === (string)new Address($browserIp); |
There was a problem hiding this comment.
I'm a bit worried about IPv6 here. With privacy addresses the same machine can show up with a different IP per connection, and with dual stack the app can come in over v6 while the browser uses v4. Both would show the warning on a normal login. Maybe compare the /64 for v6, and leave sameIp as null when one is v4 and the other v6?
There was a problem hiding this comment.
Good points!
Comparing the IPv6 /64 is a great idea. The downside is that an attacker on the same shared subnet would not trigger a warning. But that's already the case anyways for IPv4 behind NAT, so we don't loose much.
For the case when one IP is v4 and the other is v6 I'm less sure, hmmm... An attacker could easily disable the warning then by using whatever IP version the user is not using on the phishing website. Even without that info, there's a substantial chance the attacker can disable the warning by guessing the correct IP version.
There is a trade-off here: Do we want fewer false alarms for dual-stack, but then also less warnings for actual attacks? @susnux @skjnldsv
| } | ||
|
|
||
| #[PublicPage] | ||
| #[UseSession] |
There was a problem hiding this comment.
Why does this one need UseSession now? It keeps the session locked for the whole request.
There was a problem hiding this comment.
There might be a race condition when not locking the session, as state token lookup/validation could be separated from the token cleanup.
Would you recommend removing UseSession here? Or maybe close the session early in the function after line 237?
$this->session->remove(self::TOKEN_NAME);
$this->session->remove(self::STATE_NAME);
$this->session->close();Redesign the browser approval screens with clearer context, an account card with avatar, and explicit Decline and Grant actions. Show the requesting app’s IP address and display it alongside the browser IP, request age, and user agent. Indicate that the user agent is self-reported. Add popups for further information, but don't overload the user by default. Previously there were two screens: One prompting the user to login, then a second after login prompting the user to confirm. They were redundant, so this simplifies the first screen. If the user is already logged in, we now go straight to the grant screen. Add a revocation-settings link after connection. Signed-off-by: Florentin Putz <dev@fputz.net> Assisted-by: Codex:gpt-6.1-sol
When the IP addresses of the requesting client and the current browser session differ, show a prominent warning and require an additional review step. Signed-off-by: Florentin Putz <dev@fputz.net> Assisted-by: Codex:gpt-6.1-sol
740dfc1 to
c41ab65
Compare
|
Hello there, We hope that the review process is going smooth and is helpful for you. We want to ensure your pull request is reviewed to your satisfaction. If you have a moment, our community management team would very much appreciate your feedback on your experience with this PR review process. Your feedback is valuable to us as we continuously strive to improve our community developer experience. Please take a moment to complete our short survey by clicking on the following link: https://cloud.nextcloud.com/apps/forms/s/i9Ago4EQRZ7TWxjfmeEpPkf6 Thank you for contributing to Nextcloud and we hope to hear from you soon! (If you believe you should not receive this message, you can add yourself to the blocklist.) |
Summary
After analyzing phishing risks in the current login flow v2, I came up with the following improvements to mitigate the phishing risks somewhat, particularly from remote attackers (i.e., attackers with different IPs):
These changes preserve existing client APIs and legacy login flows.
Before
And then after logging in:
After
Clicking "Continue" will show the login form. After logging in:
If the IP addresses of the client and the browser differ, a warning is shown:
Steps to test my changes:
In a nextcloud client (I tested with the macOS desktop client) try to add a new account and insert the URL of your instance (e.g.
http://nextcloud.local). Then observe the redesigned login flow.To test what happens when the IP address does not match, you can do something like this to fake the IP (using the dev docker setup):
Limitations
The IP comparison requires correctly configured proxies/forwarding in the nextcloud server to prevent IP spoofing.
Checklist
3. to review, feature component)stable32)AI (if applicable)