Repository navigation
[20.0][IMP] auth_signup_verify_email: review suggestions for OCA/server-auth#1064 - #2
Conversation
- Build the signup values from an allow-list instead of passing all request params to the sudo signup (they end up in copy() of the template user). - Apply core's guards before the passwordless signup: 404 when signup is disabled, render the error on an invalid token. - Make the password xpath unambiguous: in 20.0 a second div.field-password is nested inside div.field-confirm_password. - Drop signup_login_fields: core 20.0 already uses type="email". - Tests: signup page hides the password fields, extra params are ignored, 404 when signup is disabled; drop the duplicate import. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Reviewer's GuideImplementationGuard passwordless signup using core’s checks and pass only the intended signup fields, preventing arbitrary request parameters from being copied onto the new user.
UIMake the password-field xpath target the intended field and remove the login-input override already provided by core.
TestsUpdate test setup and add coverage for hidden password fields, ignored extra signup parameters, and disabled signup.
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - I've found 3 issues
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location path="auth_signup_verify_email/controllers/main.py" line_range="56" />
<code_context>
+ values = {
+ "login": login,
+ "name": request.params.get("name"),
+ "email": request.params.get("email") or login,
+ "password": "",
+ }
</code_context>
<issue_to_address>
**Unverified login addresses can be claimed**
When an unauthenticated caller submits a valid, unclaimed victim address as `login` and an attacker-controlled address as `email` while public signup is enabled, `passwordless_signup` validates `login` but stores the caller-supplied `email`; `reset_password(login)` then sends the activation link to that stored address. An attacker can register an unclaimed victim address as the login while receiving its activation link, enabling identity squatting and impersonation.
Set the signup email to the validated login, or validate that any separately accepted email is the same address whose ownership must be verified.
</issue_to_address>
### Comment 2
<location path="auth_signup_verify_email/controllers/main.py" line_range="27-30" />
<code_context>
qcontext = self.get_auth_signup_qcontext()
+ # Same guards as core's web_auth_signup
+ if not qcontext.get("token") and not qcontext.get("signup_enabled"):
+ raise NotFound()
+ if qcontext.get("error"):
+ return request.render("auth_signup.signup", qcontext)
+
+ login = request.params.get("login", "")
</code_context>
<issue_to_address>
**GET requests create accounts**
When signup is enabled and a GET request includes a `login` parameter but no `password`, `web_auth_signup` sends any request with a `login` and no `password` to `passwordless_signup`, which proceeds to `signup()` without checking the HTTP method. A GET request can therefore create an account and send an activation email instead of only displaying the signup form.
Only run passwordless signup for POST requests; render the signup page for GET requests.
</issue_to_address>
### Comment 3
<location path="auth_signup_verify_email/controllers/main.py" line_range="55" />
<code_context>
+ # params go to a sudo copy() of the template user
+ values = {
+ "login": login,
+ "name": request.params.get("name"),
+ "email": request.params.get("email") or login,
+ "password": "",
</code_context>
<issue_to_address>
**Signup rejects missing names**
When a signup POST omits the `name` parameter, `request.params.get("name")` adds `name: None` to `values`, so `signup()` overrides the copied template user's name and required-name validation rejects account creation; the caller sees a signup error.
Add `name` to `values` only when the POST supplies it.
Also at `auth_signup_verify_email/controllers/main.py:56`.
</issue_to_address>Sourcery assessment
Needs a human reviewer. 3 findings to address first, and if the new guards or field allowlist are wrong, the signup route could reject legitimate users or create accounts with unintended values; an account or activation email already created cannot be undone by reverting, though the exposure is bounded to affected signups.
Blocking findings: auth_signup_verify_email/controllers/main.py:56, auth_signup_verify_email/controllers/main.py:30, auth_signup_verify_email/controllers/main.py:55
| values = { | ||
| "login": login, | ||
| "name": request.params.get("name"), | ||
| "email": request.params.get("email") or login, |
There was a problem hiding this comment.
🟠 High · Unverified login addresses can be claimed
When an unauthenticated caller submits a valid, unclaimed victim address as login and an attacker-controlled address as email while public signup is enabled, passwordless_signup validates login but stores the caller-supplied email; reset_password(login) then sends the activation link to that stored address. An attacker can register an unclaimed victim address as the login while receiving its activation link, enabling identity squatting and impersonation.
Set the signup email to the validated login, or validate that any separately accepted email is the same address whose ownership must be verified.
Prompt for AI agents
In `auth_signup_verify_email/controllers/main.py` at line 56:
**Unverified login addresses can be claimed**
When an unauthenticated caller submits a valid, unclaimed victim address as `login` and an attacker-controlled address as `email` while public signup is enabled, `passwordless_signup` validates `login` but stores the caller-supplied `email`; `reset_password(login)` then sends the activation link to that stored address. An attacker can register an unclaimed victim address as the login while receiving its activation link, enabling identity squatting and impersonation.
Set the signup email to the validated login, or validate that any separately accepted email is the same address whose ownership must be verified.| if not qcontext.get("token") and not qcontext.get("signup_enabled"): | ||
| raise NotFound() | ||
| if qcontext.get("error"): | ||
| return request.render("auth_signup.signup", qcontext) |
There was a problem hiding this comment.
🟡 Medium · GET requests create accounts
When signup is enabled and a GET request includes a login parameter but no password, web_auth_signup sends any request with a login and no password to passwordless_signup, which proceeds to signup() without checking the HTTP method. A GET request can therefore create an account and send an activation email instead of only displaying the signup form.
Only run passwordless signup for POST requests; render the signup page for GET requests.
Prompt for AI agents
In `auth_signup_verify_email/controllers/main.py` at lines 27-30:
**GET requests create accounts**
When signup is enabled and a GET request includes a `login` parameter but no `password`, `web_auth_signup` sends any request with a `login` and no `password` to `passwordless_signup`, which proceeds to `signup()` without checking the HTTP method. A GET request can therefore create an account and send an activation email instead of only displaying the signup form.
Only run passwordless signup for POST requests; render the signup page for GET requests.| # params go to a sudo copy() of the template user | ||
| values = { | ||
| "login": login, | ||
| "name": request.params.get("name"), |
There was a problem hiding this comment.
🟡 Medium · Signup rejects missing names
When a signup POST omits the name parameter, request.params.get("name") adds name: None to values, so signup() overrides the copied template user's name and required-name validation rejects account creation; the caller sees a signup error.
Add name to values only when the POST supplies it.
Also at auth_signup_verify_email/controllers/main.py:56.
Prompt for AI agents
In `auth_signup_verify_email/controllers/main.py` at line 55:
**Signup rejects missing names**
When a signup POST omits the `name` parameter, `request.params.get("name")` adds `name: None` to `values`, so `signup()` overrides the copied template user's name and required-name validation rejects account creation; the caller sees a signup error.
Add `name` to `values` only when the POST supplies it.
Also at `auth_signup_verify_email/controllers/main.py:56`.
These are the changes suggested in the review of OCA#1064, on top of its head (
710aa593).passwordless_signuppassed all ofrequest.paramstores.users.sudo().signup(). Without a token, that ends intemplate_user.copy(values), so any posted field (including partner fields through_inherits) was set on the new user. Now onlylogin,name,emailand an emptypasswordare passed.auth_signup.fieldsnests a seconddiv.field-passwordinsidediv.field-confirm_password. The xpath now also requireslabel[@for='password'].signup_login_fields: core 20.0 already renderstype="email"on the signup login input.ref) don't reach the userpatchimportAbout the upgrade script from OCA#1034: it removes stale website-specific copies of
auth_signup.signup, which break validation of this module's view that inherits it. That view wassignup_login_fields, which this PR removes. The only remaining view inheritsauth_signup.fields, so no script is needed.Checks: pre-commit passes on the changed files. I didn't run the Odoo tests locally; CI on OCA#1064 will run them once these changes are applied there.
🤖 Generated with Claude Code
Summary by Sourcery
Harden passwordless signup by aligning it with core signup guards, limiting accepted fields, and refining its signup form behavior.
Bug Fixes:
Enhancements:
Tests:
Chores: