Skip to main content
Menu
Advisories

Unauthenticated account takeover via reset link shown on /forgot-password

GHSA-43V4-43PW-4RP2Published Updated GitHub

Description

AFFECTED: potato-annotation 2.9.3 (PyPI), and master at commit 5a59f961547609b7b90f56554a6401cbeeee8214 (Sep 22, 2026; setup.py version 2.9.3). Any configuration with require_password: true (the default), which is where the "Forgot Password?" link is shown. No mail setup is involved: Potato does not send email.

SUMMARY POST /forgot-password creates a single-use reset token for any submitted username and renders the full reset link (/reset/<token>) in the response. The route requires no login and no admin key. Whoever submits the form can open the link and set a new password for that account.

IMPACT Anyone who can reach a Potato instance can take over any password account, including accounts holding an RBAC admin role. With an admin-role account they reach the admin dashboard and the admin endpoints that validate_admin_api_key() authorizes through RBAC. With an annotator account they can read and change that annotator's work. This falls under "authentication and session handling" in SECURITY.md.

The docs (docs/auth-users/password_management.md, "Self-Service Password Reset") describe the link as "displayed on screen for the admin to copy and share with the annotator", but the route does not check that the requester is an admin, so the link goes to whoever asked.

REPRODUCTION

  1. Start Potato with any config that has require_password: true.
  2. Register or pick an existing username, e.g. alice.
  3. In a separate browser with no session, open /forgot-password, enter alice and submit.
  4. The page shows "Reset Link: http://<host>/reset/<token>".
  5. Open the link, set a new password, submit.
  6. Log in as alice with the new password.

The existing test tests/server/test_password_reset_api.py::test_forgot_password_known_user_shows_link asserts this behavior (an unauthenticated session gets "/reset/" in the response); it passes on master 5a59f96.

PROPOSED FIX (patch below)

  • /forgot-password no longer creates or shows a token. For any username, known or not, it returns the same page telling the annotator to ask the administrator for a reset link. The enumeration-safe single response is kept.
  • Reset links are issued only through the existing admin paths: POST /admin/create_reset_token (admin key or RBAC admin) and the potato reset-password CLI. /reset/<token> is unchanged.
  • No new config key. Since Potato has no mail backend, there is no safe channel for a self-service link, so a toggle to turn it back on would only reopen the issue. If you later add email delivery, the route could send the link there instead; happy to change the approach if you prefer a config-gated shape.
  • Test updated to assert the link is not shown, plus a test that known and unknown usernames get identical responses. tests/server/test_password_reset_api.py: 12 passed locally.
  • Docs updated to describe the admin-issued flow.

Workaround until a release: block /forgot-password at the reverse proxy, and issue resets with the admin API or CLI.

We have not published details of this issue anywhere. We are glad to adjust the patch, and fine with credit to HDEF (hdef-devteam) in the advisory.

PATCH

diff --git a/docs/auth-users/password_management.md b/docs/auth-users/password_management.md
index af36805..b227bc5 100644
--- a/docs/auth-users/password_management.md
+++ b/docs/auth-users/password_management.md
@@ -10,7 +10,7 @@ Potato's authentication system supports:
 
 - **Per-user salted password hashing** using PBKDF2-SHA256 with 100,000 iterations
 - **Admin-initiated password reset** via CLI command or REST API
-- **Self-service password reset** via token-based reset links
+- **Token-based reset links** issued by an administrator
 - **Shared user credential files** for multi-server deployments
 - **Database authentication backend** using SQLite or PostgreSQL
 
@@ -75,19 +75,19 @@ curl -X POST http://localhost:8000/admin/reset_password \
 
 This endpoint requires the `admin_api_key` configured in your project (see [Admin Dashboard](../administration/admin_dashboard.md)).
 
-### Self-Service Password Reset
+### Reset Links
 
 Potato includes a token-based password reset flow for annotators who forget their passwords.
 
-#### The self-service reset flow
+#### The reset flow
 
-1. The annotator visits `/forgot-password` and enters their username
-2. The system generates a secure single-use reset token (valid for 24 hours)
-3. The reset link is displayed on screen for the admin to copy and share with the annotator
+1. The annotator visits `/forgot-password`, enters their username, and is told to contact the administrator
+2. The administrator generates a secure single-use reset token (valid for 24 hours) with the API below
+3. The administrator sends the link to the annotator via email or chat
 4. The annotator opens the link (`/reset/<token>`) and sets a new password
 5. The token is consumed (single-use) and the password is updated
 
-> **Note:** Potato does not send emails. The reset link is displayed on the page after submission. In a typical workflow, an administrator generates the token and sends the link to the annotator via email or chat.
+> **Note:** Potato does not send emails, so `/forgot-password` never shows a reset link. Anyone can submit that form, and showing the link there would let them reset any account, including an admin's. Reset links come only from the admin API or the `potato reset-password` CLI.
 
 #### Generating Tokens via API
 
@@ -113,7 +113,7 @@ Optional: set a custom expiry with `"ttl_hours": 48`.
 
 #### Login Page Link
 
-When `require_password: true` is set, a "Forgot Password?" link appears on the login page, directing annotators to the self-service reset form.
+When `require_password: true` is set, a "Forgot Password?" link appears on the login page, directing annotators to a page that tells them to ask the administrator for a reset link.
 
 ## Where accounts are stored
 
diff --git a/potato/routes.py b/potato/routes.py
index 10ac568..be01d69 100644
--- a/potato/routes.py
+++ b/potato/routes.py
@@ -9465,34 +9465,33 @@ def admin_create_reset_token():
 def forgot_password():
     """Self-service forgot password page.
 
+    Potato does not send email, so there is no channel that proves the
+    requester owns the account. The page therefore never creates or shows a
+    reset token: it tells the annotator to ask an administrator, who can issue
+    a link with ``POST /admin/create_reset_token`` or reset the password with
+    ``potato reset-password``.
+
     GET: Show the forgot password form.
-    POST: Generate a reset token and display the reset link.
+    POST: Show the same instructions for any username.
     """
     if request.method == "GET":
         return render_template("forgot_password.html",
                              title=config.get("annotation_task_name", "Annotation Platform"))
 
     username = request.form.get("username", "").strip()
-    # Always show success to prevent user enumeration
     if not username:
         return render_template("forgot_password.html",
                              title=config.get("annotation_task_name", "Annotation Platform"),
                              error="Please enter your username.")
 
-    user_authenticator = UserAuthenticator.get_instance()
-    token = user_authenticator.create_reset_token(username)
-
-    if token:
-        reset_link = f"{request.host_url.rstrip('/')}/reset/{token}"
-        return render_template("forgot_password.html",
-                             title=config.get("annotation_task_name", "Annotation Platform"),
-                             reset_link=reset_link,
-                             success=True)
-    else:
-        # Show same success message to prevent enumeration
-        return render_template("forgot_password.html",
-                             title=config.get("annotation_task_name", "Annotation Platform"),
-                             success=True)
+    # Same response whether or not the user exists, to prevent enumeration.
+    # No token is created here: a link handed to whoever typed the username
+    # would let anyone reset any account.
+    logger.info("Password reset requested via /forgot-password; "
+                "an administrator must issue the reset link")
+    return render_template("forgot_password.html",
+                         title=config.get("annotation_task_name", "Annotation Platform"),
+                         success=True)
 
 
 def reset_password_with_token(token):
diff --git a/potato/templates/forgot_password.html b/potato/templates/forgot_password.html
index d962e74..dc22472 100644
--- a/potato/templates/forgot_password.html
+++ b/potato/templates/forgot_password.html
@@ -25,19 +25,11 @@
             {% if success %}
             <div class="potato-alert" style="background-color: #d4edda; color: #155724; border: 1px solid #c3e6cb; border-radius: 0.375rem; padding: 0.75rem 1rem; margin-bottom: 1rem;">
                 <i class="fas fa-check-circle me-1"></i>
-                If the username exists, a reset link has been generated.
+                Password resets are handled by your administrator.
             </div>
-            {% if reset_link %}
-            <div style="margin-bottom: 1rem;">
-                <label class="potato-form-label">Reset Link</label>
-                <div style="background: #f8f9fa; border: 1px solid #dee2e6; border-radius: 0.375rem; padding: 0.75rem; word-break: break-all; font-size: 0.85rem;">
-                    <a href="{{ reset_link }}">{{ reset_link }}</a>
-                </div>
-                <p style="font-size: 0.8rem; color: #6c757d; margin-top: 0.5rem;">
-                    Share this link with the user or use it to reset your password. It expires in 24 hours.
-                </p>
-            </div>
-            {% endif %}
+            <p style="font-size: 0.875rem; color: #6c757d; margin-bottom: 1rem;">
+                Contact the person running this annotation task and ask for a password reset link.
+            </p>
             {% else %}
             <form method="POST" action="{{ url_prefix }}/forgot-password">
                 <div class="potato-form-group">
diff --git a/tests/server/test_password_reset_api.py b/tests/server/test_password_reset_api.py
index 117a67b..b1fee01 100644
--- a/tests/server/test_password_reset_api.py
+++ b/tests/server/test_password_reset_api.py
@@ -168,8 +168,12 @@ class TestPasswordResetAPI:
         # Should show generic success, not an error
         assert "error" not in resp.text.lower() or "exists" not in resp.text.lower()
 
-    def test_forgot_password_known_user_shows_link(self):
-        """POST /forgot-password with known user shows reset link."""
+    def test_forgot_password_known_user_does_not_show_link(self):
+        """POST /forgot-password never hands a reset link to the requester.
+
+        Anyone can submit this form, so returning a link would let them reset
+        any account. Links are issued only by an admin.
+        """
         session = requests.Session()
         self._register_user(session, "forgot_user", "mypass")
 
@@ -178,4 +182,20 @@ class TestPasswordResetAPI:
             data={"username": "forgot_user"},
         )
         assert resp.status_code == 200
-        assert "/reset/" in resp.text
+        assert "/reset/" not in resp.text
+        assert "administrator" in resp.text.lower()
+
+    def test_forgot_password_same_response_for_unknown_user(self):
+        """Known and unknown usernames get the same page (no enumeration)."""
+        session = requests.Session()
+        self._register_user(session, "forgot_user2", "mypass")
+
+        known = session.post(
+            f"{self.server.base_url}/forgot-password",
+            data={"username": "forgot_user2"},
+        )
+        unknown = session.post(
+            f"{self.server.base_url}/forgot-password",
+            data={"username": "no_such_user_abc"},
+        )
+        assert known.text == unknown.text

Affected versions

References

GitHub · davidjurgens/potato