Reject workflow state from seed signing links
What changed, and why it matters
This commit changes how BTCPay Server handles wallet signing links that use a stored seed. Previously, clicking a 'seed' signing link could automatically carry over a pending transaction and original PSBT (a partially-signed Bitcoin transaction) from the user's workflow state. The patch makes the seed signing page discard that workflow state and only accept signing context supplied directly in the link. This likely closes a security issue where a malicious or crafted link could trick a user into signing a different transaction than expected by reusing state from a previous session.
Review whether other signing methods (vault, hardware wallet, etc.) similarly sanitize workflow state before rendering signing pages. Consider adding tests that verify a seed signing link with a stale PendingTransactionId does not sign the wrong PSBT. No immediate emergency action is indicated, but the fix should be included in the next release.
Security signals we found
State-clearing before sensitive signing operation
Separation of stateful entry point from direct view rendering
Prevents reuse of PendingTransactionId/OriginalPSBT from prior workflow state
Title explicitly frames change as 'Reject workflow state from seed signing links'
Evidence from the diff
The patch modifies UIWalletsController.cs so that the SignWithSeed GET action now explicitly clears signingContext.PendingTransactionId and signingContext.OriginalPSBT before rendering the seed signing view. It also splits the view-rendering logic into a private ViewSignWithSeed helper. The PSBT controller’s WalletSign action now calls ViewSignWithSeed directly for the ‘seed’ case instead of SignWithSeed, preventing workflow state from being passed through. The PayButton changes are test/selector updates unrelated to the security fix.
Changed components
BTCPayServer/Plugins/Wallets/Controllers/UIWalletsController.csBTCPayServer/Plugins/Wallets/Controllers/UIWalletsController.PSBT.csBTCPayServer seed-based transaction signing flowInspect 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 57/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.