What changed, and why it matters
This change makes the logout action require a POST request instead of a simple link click (GET). The old GET-based logout could potentially be triggered by a malicious web page tricking a logged-in user's browser into visiting the /logout URL, logging them out unexpectedly. By switching to a POST form button, the logout can no longer be triggered by a simple embedded link or image, which is a standard defense against cross-site request forgery (CSRF)-style logout attacks. The patch also updates tests and navigation UI to use the new POST form.
Review whether other state-changing endpoints in the application still accept GET requests and consider migrating them to POST/PUT/DELETE with anti-forgery tokens. Verify that the logout form includes the ASP.NET Core anti-forgery token (@Html.AntiForgeryToken is implicitly included by asp-action forms) and that the action validates it. No immediate emergency response is indicated, but the change should be included in the next release.
Security signals we found
State-changing action moved from GET to POST
Logout endpoint previously reachable by simple URL navigation
UI logout control converted from anchor to form submission
Test suite updated to reflect new logout interaction pattern
Evidence from the diff
The commit changes UIAccountController.Logout from [HttpGet(“/logout”)] to [HttpPost(“/logout”)]. The global navigation and store invitation views are updated to wrap the logout action in a
Changed components
BTCPayServer/Controllers/UIAccountController.csBTCPayServer/Components/GlobalNav/Default.cshtmlBTCPayServer/Views/UIUserStores/AcceptStoreInvitation.cshtmlBTCPayServer.Tests/PlaywrightTester.csBTCPayServer.Tests/PlaywrightTests.csBTCPayServer.Tests/RolesTests.csInspect captured patch +14 / −11
### BTCPayServer.Tests/PlaywrightTester.cs
@@ -362,7 +362,7 @@ public async Task GoToLogin()
public async Task Logout()
{
await Page.Locator("#menu-item-Account").ClickAsync();
- await Page.Locator("#Nav-Logout").ClickAsync();
+ await Page.Locator(".global-nav__logout").ClickAsync();
}
public Task SkipWizard() => Page.ClickAsync("#SkipWizard");
@@ -455,7 +455,7 @@ public async Task ClickOnAllSectionLinks(string sectionSelector = "#menu-item")
foreach (var locator in await linkLocator.AllAsync())
{
var link = await locator.GetAttributeAsync("href");
- if (link is null or "/logout")
+ if (link is null)
continue;
Assert.NotNull(link);
links.Add(link);
### BTCPayServer.Tests/PlaywrightTests.cs
@@ -87,7 +87,6 @@ public async Task CanUseForms()
invoiceId = s.Page.Url[(s.Page.Url.LastIndexOf("/", StringComparison.Ordinal) + 1)..];
}
- await s.Page.Context.Pages.First().BringToFrontAsync();
await s.GoToUrl($"/invoices/{invoiceId}/");
await Expect(s.Page.Locator("text=aa@aa.com")).ToBeVisibleAsync();
// Payment Request
@@ -108,7 +107,6 @@ public async Task CanUseForms()
await popOutPage.ClickAsync("#page-primary");
invoiceId = popOutPage.Url.Split('/').Last();
await popOutPage.CloseAsync();
- await s.Page.Context.Pages.First().BringToFrontAsync();
await s.GoToUrl(editUrl.PathAndQuery);
await Expect(s.Page.Locator("#Email")).ToHaveValueAsync("aa@aa.com");
@@ -2035,7 +2033,8 @@ public async Task CookieReflectProperPermissions()
Policies.CanModifyServerSettings
});
- await s.GoToUrl("/logout");
+ await s.GoToHome();
+ await s.Logout();
await alice.MakeAdmin();
await s.GoToLogin();
### BTCPayServer.Tests/RolesTests.cs
@@ -776,7 +776,7 @@ public async Task ServerRolesLinkedCorrectlyFromStoreRolesPage()
Assert.DoesNotContain($"/stores/{storeId}/roles/", serverRoleUrl);
// Verify we can see the permissions form
- await Expect(s.Page.Locator("form")).ToBeVisibleAsync();
+ await Expect(s.Page.Locator("#mainContent form")).ToBeVisibleAsync();
// Verify we have permission checkboxes
await Expect(s.Page.Locator("input.policy-cb")).Not.ToHaveCountAsync(0);
### BTCPayServer/Components/GlobalNav/Default.cshtml
@@ -179,9 +179,11 @@
}
<li><hr class="dropdown-divider" /></li>
<li>
- <a asp-area="" asp-controller="UIAccount" asp-action="Logout" class="dropdown-item text-danger" id="Nav-Logout">
- <span text-translate="true">Logout</span>
- </a>
+ <form method="post" asp-area="" asp-controller="UIAccount" asp-action="Logout">
+ <button type="submit" class="dropdown-item text-danger global-nav__logout" id="Nav-Logout">
+ <span text-translate="true">Logout</span>
+ </button>
+ </form>
</li>
</ul>
</div>
### BTCPayServer/Controllers/UIAccountController.cs
@@ -600,7 +600,7 @@ public async Task<IActionResult> Register(RegisterViewModel model, string return
public string RegisteredUserId { get; set; }
public bool RegisteredAdmin { get; set; }
- [HttpGet("/logout")]
+ [HttpPost("/logout")]
public async Task<IActionResult> Logout()
{
await signInManager.SignOutAsync();
### BTCPayServer/Views/UIUserStores/AcceptStoreInvitation.cshtml
@@ -34,7 +34,9 @@
}
</p>
<div class="d-grid gap-3 mt-4">
- <a asp-controller="UIAccount" asp-action="Logout" class="btn btn-primary" text-translate="true">Sign in as another user</a>
+ <form method="post" asp-controller="UIAccount" asp-action="Logout" class="d-grid">
+ <button type="submit" class="btn btn-primary store-invitation__logout" text-translate="true">Sign in as another user</button>
+ </form>
<a asp-action="ListStores" class="btn btn-secondary" text-translate="true">Back to stores</a>
</div>
}Why this scored 52/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.