From 827de50fc0b623a21cc5a8fe52111382ffd2006d Mon Sep 17 00:00:00 2001 From: TaprootFreak <142087526+TaprootFreak@users.noreply.github.com> Date: Tue, 6 Jan 2026 22:22:14 +0100 Subject: [PATCH] Merge pull request #2860 from DFXswiss/fix/unassigned-transaction-refund-ownership-check fix: correct ownership check for unassigned transaction refunds --- .../history/controllers/transaction.controller.ts | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/subdomains/core/history/controllers/transaction.controller.ts b/src/subdomains/core/history/controllers/transaction.controller.ts index b5f9fb076c..4f29e7b642 100644 --- a/src/subdomains/core/history/controllers/transaction.controller.ts +++ b/src/subdomains/core/history/controllers/transaction.controller.ts @@ -323,9 +323,15 @@ export class TransactionController { if (transaction.refundTargetEntity instanceof BankTx) { // Unassigned transaction if (!BankTxTypeUnassigned(transaction.bankTx.type)) throw new NotFoundException('Transaction not found'); - const txOwner = await this.bankTxService.getUserDataForBankTx(transaction.bankTx, jwt.account); - if (jwt.account !== transaction.userData?.id || txOwner.id !== jwt.account) + + // Check ownership (consistent with requestRefund logic) + if (transaction.userData && jwt.account !== transaction.userData.id) throw new ForbiddenException('You can only refund your own transaction'); + if (!transaction.userData) { + const txOwner = await this.bankTxService.getUserDataForBankTx(transaction.bankTx, jwt.account); + if (txOwner?.id !== jwt.account) throw new ForbiddenException('You can only refund your own transaction'); + } + if (transaction.refundTargetEntity.bankTxReturn) throw new BadRequestException('You can only refund a transaction once'); @@ -421,7 +427,7 @@ export class TransactionController { throw new ForbiddenException('You can only refund your own transaction'); if (!transaction.targetEntity && !transaction.userData) { const txOwner = await this.bankTxService.getUserDataForBankTx(transaction.bankTx, jwt.account); - if (txOwner.id !== jwt.account) throw new ForbiddenException('You can only refund your own transaction'); + if (txOwner?.id !== jwt.account) throw new ForbiddenException('You can only refund your own transaction'); } const refundData = this.refundList.get(transaction.id);