Merge pull request #7713 from btcpayserver/security/seed-signing-pending-id
What changed, and why it matters
This commit changes how BTCPay Server handles signing cryptocurrency transactions with a stored wallet seed. Previously, a user could be sent straight to the seed-signing screen carrying a pre-loaded transaction (a 'pending transaction' and original PSBT). The patch forces that screen to drop any pre-loaded transaction data, so the user must review the transaction before signing. In short, it removes a path that could let an attacker trick someone into signing a transaction they never saw. The rest of the changes are just test and UI tweaks for the Pay Button feature and are not security-related.
Treat this as a security hardening fix and include it in the next release. Users running affected versions should upgrade. Review whether any other signing paths (hardware wallet, vault, hot wallet) similarly allow pre-loaded transactions to bypass review.
Security signals we found
Clearing of PendingTransactionId and OriginalPSBT before rendering seed-signing view
Separation of HTTP GET entry point from view-rendering helper to control context flow
Pull request branch named security/seed-signing-pending-id
Commit title explicitly references 'Require transaction review for linked seed signing'
Evidence from the diff
The security-relevant change is in UIWalletsController.cs. The existing [HttpGet] SignWithSeed action now clears signingContext.PendingTransactionId and signingContext.OriginalPSBT before rendering the view, and the actual view rendering is moved to a private ViewSignWithSeed helper. The WalletSign POST action’s ‘seed’ branch now calls ViewSignWithSeed directly instead of SignWithSeed, so any pending-transaction context is stripped when the seed-signing page is first shown. This enforces transaction review before seed-based signing. The Pay Button changes (new CSS class and updated test selector) are unrelated to the security fix.
Changed components
BTCPayServer/Plugins/Wallets/Controllers/UIWalletsController.csBTCPayServer/Plugins/Wallets/Controllers/UIWalletsController.PSBT.csInspect captured patch +14 / −5
### BTCPayServer.Tests/PlaywrightTests.cs
@@ -181,11 +181,13 @@ public async Task CanUsePayButtonFromExternalWebsite()
await s.GoToStore(s.StoreId, StoreNavPages.PayButton);
await s.Page.Locator("#enable-pay-button").ClickAsync();
+ var generatedCode = s.Page.Locator(".pay-button__generated-code");
+ await Expect(generatedCode).ToContainTextAsync("btcpay-form");
await s.Page.Locator("#price").FillAsync("10");
await s.Page.Locator("#useModal").CheckAsync();
- await Expect(s.Page.Locator("#mainCode")).ToContainTextAsync("modal/btcpay.js");
+ await Expect(generatedCode).ToContainTextAsync("modal/btcpay.js");
await s.Page.WaitForFunctionAsync("() => !!window.btcpay");
- var payButtonCode = await s.Page.Locator("#mainCode").InnerTextAsync();
+ var payButtonCode = await generatedCode.InnerTextAsync();
using var merchantServer = new FakeServer();
await merchantServer.Start();
### BTCPayServer/Plugins/PayButton/Views/PayButton.cshtml
@@ -400,7 +400,7 @@
<h4 class="mt-5 mb-3" text-translate="true">Generated Code</h4>
<div class="row" v-show="!errors.any()">
<div class="col-xxl-8">
- <pre><code id="mainCode" class="html"></code></pre>
+ <pre><code id="mainCode" class="html pay-button__generated-code"></code></pre>
<button class="btn btn-outline-secondary clipboard-button" data-clipboard-target="#mainCode">
<vc:icon symbol="actions-copy"/> <span text-translate="true">Copy Code</span>
</button>
### BTCPayServer/Plugins/Wallets/Controllers/UIWalletsController.PSBT.cs
@@ -99,7 +99,7 @@ public async Task<IActionResult> WalletSign([ModelBinder(typeof(WalletIdModelBin
case "vault":
return ViewVault(walletId, vm);
case "seed":
- return await SignWithSeed(walletId, vm.SigningContext, vm.ReturnUrl, vm.BackUrl);
+ return ViewSignWithSeed(vm.SigningContext, vm.ReturnUrl, vm.BackUrl);
case "decode":
return await WalletPSBT(walletId, vm, "decode");
}
### BTCPayServer/Plugins/Wallets/Controllers/UIWalletsController.cs
@@ -1719,8 +1719,15 @@ private IActionResult RedirectToWalletPSBT(WalletPSBTViewModel vm)
[HttpGet("{walletId}/psbt/seed")]
[Authorize(Policy = WalletPolicies.CanSignWalletTransactions, AuthenticationSchemes = AuthenticationSchemes.Cookie)]
- public async Task<IActionResult> SignWithSeed([ModelBinder(typeof(WalletIdModelBinder))] WalletId walletId,
+ public IActionResult SignWithSeed([ModelBinder(typeof(WalletIdModelBinder))] WalletId walletId,
SigningContextModel signingContext, string? returnUrl, string? backUrl)
+ {
+ signingContext.PendingTransactionId = null;
+ signingContext.OriginalPSBT = null;
+ return ViewSignWithSeed(signingContext, returnUrl, backUrl);
+ }
+
+ private IActionResult ViewSignWithSeed(SigningContextModel signingContext, string? returnUrl, string? backUrl)
{
return View(nameof(SignWithSeed), new SignWithSeedViewModel
{Why this scored 55/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.