user-reauth: the user form asks for your account password (audit A2)
Security audit 2026-10-17, finding A2 (high), stage 0; the mockup is
2c27275. A stolen global session could set its own password on the user
form - no current password asked, the session kept - and then pass the
backup's reauth with it, or add a second global user with a known
password. Now the user form calls reauth (the backup's check: bcrypt
against the signed-in user's own hash, under auth.AllowPasswordChange) when
it adds a user and when a save sets a password, changes the e-mail (reset
links go there) or changes the role, the own account included; deleting a
user asks too, refused on its own confirmation page (renderUserDelete, a
Flash on UserDelete). Name and reach alone are not asked. Missing or wrong:
401 on the same page, "Your account password is incorrect.", nothing saved.
Tests: TestUserFormAsksForTheAccountPassword (create, each of password,
e-mail, role, own password, reach alone, delete); the user-form tests send
the field (withAccountPassword gives root a real hash and h an auth
module). go vet, go test ./internal/web/... on Windows.
Docs: security.md § Backup and domain export, guide § Users, help word for
word with the mockup; CHANGELOG [Unreleased] Security; plan line ticked.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -286,6 +286,7 @@ func TestUserDeletePageNamesTheAssignmentsAndRefusalsStayOnTheForm(t *testing.T)
|
||||
out1, _ := st.AddDomain("out.example.com", "mail")
|
||||
in1, _ := st.AddInboundDomain("in.example.com")
|
||||
root := userWith(t, st, "root", store.RoleGlobal, store.Reach{})
|
||||
withAccountPassword(t, h, st, root)
|
||||
u := userWith(t, st, "shop", store.RoleDomain, store.Reach{DomainIDs: []int64{out1.ID}, InboundDomainIDs: []int64{in1.ID}})
|
||||
|
||||
path := "/server/users/" + idStr(u.ID) + "/delete"
|
||||
@@ -294,6 +295,7 @@ func TestUserDeletePageNamesTheAssignmentsAndRefusalsStayOnTheForm(t *testing.T)
|
||||
`<h1 class="title is-3">Delete shop</h1>`, `<div class="box sp-danger-zone">`,
|
||||
`remove the assignments to <strong>out.example.com</strong> (outbound) and to <strong>in.example.com</strong> (inbound).`,
|
||||
`<form method="post" action="` + path + `">`, `href="/server/users/` + idStr(u.ID) + `">Keep it`,
|
||||
`name="account_password" type="password" autocomplete="current-password" required`,
|
||||
} {
|
||||
if !strings.Contains(body, want) {
|
||||
t.Errorf("the delete page is missing %q", want)
|
||||
@@ -309,7 +311,7 @@ func TestUserDeletePageNamesTheAssignmentsAndRefusalsStayOnTheForm(t *testing.T)
|
||||
if _, err := st.GetUser(root.ID); err != nil {
|
||||
t.Errorf("the refused delete removed the user: %v", err)
|
||||
}
|
||||
if rec := send(h.HandleUserDelete, &root, "POST", path, map[string]string{"uid": idStr(u.ID)}, url.Values{}); rec.Code != http.StatusSeeOther {
|
||||
if rec := send(h.HandleUserDelete, &root, "POST", path, map[string]string{"uid": idStr(u.ID)}, url.Values{"account_password": {testAccountPassword}}); rec.Code != http.StatusSeeOther {
|
||||
t.Errorf("deleting another user = %d", rec.Code)
|
||||
}
|
||||
if _, err := st.GetUser(u.ID); err == nil {
|
||||
|
||||
Reference in New Issue
Block a user