Skip to content

Improve login flow v2 approval pages and warn about IP mismatch - #66223

Open
fput wants to merge 5 commits into
nextcloud:masterfrom
fput:improve-login-flow
Open

fput wants to merge 5 commits into
nextcloud:masterfrom
fput:improve-login-flow

Conversation

@fput

@fput fput commented Nov 3, 2026 •

Copy link
Copy Markdown

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):

  • 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 help popups for further information, but don't overload the user by default.
  • Show a prominent warning when IPs differ and require an additional review step.
  • Redesign the browser approval screens with clearer context, an account card with avatar, and explicit Decline and Grant actions.
  • Make declining invalidate the pending request.

These changes preserve existing client APIs and legacy login flows.

Before

before1

And then after logging in:

before2

After

after1

Clicking "Continue" will show the login form. After logging in:

after2

If the IP addresses of the client and the browser differ, a warning is shown:

after3

Steps to test my changes:

# Repository root, using Node 24
npm ci
npm --prefix build/frontend run build

# Inside the PHP environment, as the web-server user
php occ migrations:migrate core

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):

# create a login request
curl -sS -X POST \
  -A 'IP mismatch preview' \
  http://nextcloud.local/index.php/login/v2 |
  python3 -c 'import json,sys; print(json.load(sys.stdin)["login"])'

# update the IP of the client in the DB so that there is a mismatch
docker exec --user www-data master-nextcloud-1 php -r '
require_once "lib/base.php";
$query = \OCP\Server::get(\OCP\IDBConnection::class)->getQueryBuilder();
$query->update("login_flow_v2")
    ->set("client_ip", $query->createNamedParameter("203.0.113.42"))
    ->where($query->expr()->eq("client_name", $query->createNamedParameter("IP mismatch preview")))
    ->andWhere($query->expr()->isNull("app_password"))
    ->executeStatement();'

# now go to the URL the first command returned and observe the warning in the login flow

Limitations

The IP comparison requires correctly configured proxies/forwarding in the nextcloud server to prevent IP spoofing.

Checklist

AI (if applicable)

  • The content of this PR was partly or fully generated using AI: I used Codex for implementing and iterating over the changes after I came up with the redesign ideas.

fput added 4 commits November 3, 2026 19:18
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
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.

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
@fput
fput marked this pull request as ready for review November 3, 2026 19:18
@fput
fput requested review from a team as code owners November 3, 2026 19:18
@fput
fput requested review from Altahrim, icewind1991, kristian-zendato, pringelmann, salmart-dev, skjnldsv and sorbaugh and removed request for a team November 3, 2026 19:18
@susnux susnux added this to the Nextcloud 36 milestone Nov 3, 2026
@susnux susnux added enhancement design Design, UI, UX, etc. 3. to review Waiting for reviews feature: authentication labels Nov 3, 2026

This branch has not been deployed

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Make login flow v2 more phishing proof

2 participants