#19952·OrchardCore

Users admin list: search, filters and bulk actions return 400 when a listed user has an unconfirmed email (nested forms duplicate the antiforgery token)

Author: SzymonSelCreated Sep 28, 2026Updated Sep 28, 2026

Describe the bug

On /Admin/Users/Index, searching, changing a filter/sort dropdown, or running a bulk action returns 400 Bad Request whenever the current page lists a user whose email is not confirmed. Nothing is logged above Information level, so it looks like a silent failure.

The cause is nested forms. UserSendConfirmationActionsMenu (and UserTwoFactorActionsMenu) render their own <form method="post">, with its own antiforgery token, inside each row's actions dropdown. That dropdown lives inside the list's <form asp-action="Index"> from Views/Admin/Index.cshtml. Browsers don't allow nested forms: the parser drops the inner <form> start tag but keeps its inputs, so they belong to the list form. The inner </form> then closes the list form early.

Since #19513 added <div data-list-management> to UsersAdminList.cshtml without a closing </div>, the list form's own token also stays inside that still-open div, so the list form ends up posting two __RequestVerificationToken values. ASP.NET joins them with a comma, and the combined value can't be decoded:

Antiforgery token validation failed. The antiforgery token could not be decrypted.
Microsoft.AspNetCore.Antiforgery.AntiforgeryValidationException: The antiforgery token could not be decrypted.
 ---> System.FormatException: Malformed input: 397 is an invalid input length.
   at Microsoft.AspNetCore.WebUtilities.WebEncoders.GetNumBase64PaddingCharsToAddForDecode(Int32 inputLength)
   ...
   at Microsoft.AspNetCore.Antiforgery.DefaultAntiforgeryTokenSerializer.Deserialize(String serializedToken)
   at Microsoft.AspNetCore.Mvc.ViewFeatures.Filters.ValidateAntiforgeryTokenAuthorizationFilter.OnAuthorizationAsync(AuthorizationFilterContext context)
Authorization failed for the request at filter 'Microsoft.AspNetCore.Mvc.ViewFeatures.Filters.AutoValidateAntiforgeryTokenAuthorizationFilter'.
Executing StatusCodeResult, setting HTTP status code 400

(397 = two ~198-character tokens + a comma.)

The nested forms themselves date back to #16899 / #17050. Before #19513 the bug was masked: the list form's own token landed outside the form, so the list form posted exactly one token, borrowed from the first nested form, which happens to validate. It also posts a stray id from that nested form.

Orchard Core version

4.0.0-preview-19153 (NuGet). The relevant markup is unchanged on main as of 2a8f24e155 (2026-09-27):

To Reproduce

  1. Enable Users Registration (OrchardCore.Users.Registration) and turn on Users must validate their email in the registration settings.
  2. Make sure at least one user with EmailConfirmed = false appears on the current page of Security → Users. Log in as an admin with Edit users permission, so the "Send verification email" menu item renders for that user.
  3. Type anything in the search box and press Enter, or change the status/sort/role filter.
  4. The browser receives 400 Bad Request.

The same should happen with OrchardCore.Users.2FA for a listed user who has two-factor enabled, since UserTwoFactorActionsMenu uses the same nested-form pattern. We only observed the email-confirmation case directly.

It isn't theme-specific. We hit it on tenants running TheAdmin and on one running a custom admin theme, and neither overrides these shapes.

Expected behavior

Search, filters and bulk actions work regardless of which users are listed, and each form posts a single antiforgery token.

Suggested fix

Don't render forms inside the list form. Either of these works:

  • Use the same data-url-af link pattern UserActionsMenu.cshtml already uses for Disable/Enable/Unlock, e.g. <a asp-action="SendVerificationEmail" asp-controller="EmailConfirmation" asp-route-id="@Model.User.UserId" class="dropdown-item" data-url-af="UnsafeUrl">…</a>
  • Or a submit button that posts the enclosing list form to the action, which carries that form's single token: <button type="submit" asp-action="SendVerificationEmail" asp-controller="EmailConfirmation" name="id" value="@Model.User.UserId" class="dropdown-item">…</button>

Closing the <div data-list-management> in UsersAdminList.cshtml makes the 400 go away, and #19845 does that as part of its rewrite. But #19845 keeps the nested forms in both menus, so the list form would still borrow a token from the first nested form and post a stray id.