wizard: guard against unexpected number of txes in tx set
What changed, and why it matters
This commit adds safety checks to Feather Wallet's transaction wizard. It now rejects transaction files that contain zero transactions or more than one transaction, showing an error instead of continuing. This prevents the wallet from mishandling malformed or unexpected transaction sets during offline signing and normal transaction creation.
Review whether downstream consumers of PendingTransaction elsewhere in the codebase also assume exactly one transaction and add similar guards if needed. Consider whether txCount() > 1 should be treated as a security-relevant invariant with a consistent error message across all paths.
Security signals we found
Defensive validation added for transaction set cardinality
Multiple code paths previously lacking txCount checks now reject empty or multi-tx sets
User-facing error dialogs prevent silent progression on malformed input
Offline transaction signing workflow is the primary beneficiary
Evidence from the diff
The patch hardens multiple transaction import/creation paths by validating PendingTransaction::txCount() before proceeding. Previously, only the normal transaction creation path checked for 0 or >1 transactions. The offline signing wizard pages (import unsigned, import signed, import offline) and the signed-transaction loader in MainWindow now also enforce exactly one transaction per set. The change is defensive and prevents downstream code from operating on empty or multi-tx sets.
Changed components
src/MainWindow.cppsrc/wizard/offline_tx_signing/PageOTS_ImportOffline.cppsrc/wizard/offline_tx_signing/PageOTS_ImportSignedTx.cppsrc/wizard/offline_tx_signing/PageOTS_ImportUnsignedTx.cppInspect captured patch +67 / −3
diff --git a/src/MainWindow.cpp b/src/MainWindow.cpp
index 309b9a5..9544941 100644
--- a/src/MainWindow.cpp
+++ b/src/MainWindow.cpp
@@ -931,12 +931,12 @@ void MainWindow::onTransactionCreated(PendingTransaction *tx, const QVector<QStr
m_wallet->disposeTransaction(tx);
return;
}
- else if (tx->txCount() == 0) {
+ if (tx->txCount() == 0) {
Utils::showError(this, "Failed to construct transaction", "No transactions were constructed", {"You have found a bug. Please contact the developers."}, "report_an_issue");
m_wallet->disposeTransaction(tx);
return;
}
- else if (tx->txCount() > 1) {
+ if (tx->txCount() > 1) {
Utils::showError(this, "Failed to construct transaction", "Transaction tries to spend too many inputs", {"Send a smaller amount of XMR to yourself first."});
m_wallet->disposeTransaction(tx);
return;
@@ -1141,8 +1141,18 @@ void MainWindow::showKeyImageSyncWizard() {
#ifdef WITH_SCANNER
OfflineTxSigningWizard wizard{this, m_wallet};
wizard.exec();
-
+
if (wizard.readyToSign()) {
+ if (wizard.unsignedTransaction()->txCount() == 0) {
+ Utils::showError(this, "Unable to load unsign transaction", "Unsigned transaction set contains no transactions");
+ return;
+ }
+
+ if (wizard.unsignedTransaction()->txCount() > 1) {
+ Utils::showError(this, "Unable to load unsign transaction", "Unsigned transaction set contains more than one transaction");
+ return;
+ }
+
TxConfAdvDialog dialog{m_wallet, "", this, true};
dialog.setUnsignedTransaction(wizard.unsignedTransaction());
auto r = dialog.exec();
@@ -1403,6 +1413,18 @@ void MainWindow::loadSignedTx() {
return;
}
+ if (tx->txCount() == 0) {
+ Utils::showError(this, "Unable to load signed transaction", "Signed transaction set contains no transactions");
+ m_wallet->disposeTransaction(tx);
+ return;
+ }
+
+ if (tx->txCount() > 1) {
+ Utils::showError(this, "Unable to load signed transaction", "Signed transaction set contains more than one transaction");
+ m_wallet->disposeTransaction(tx);
+ return;
+ }
+
TxConfAdvDialog dialog{m_wallet, "", this, true};
dialog.setTransaction(tx);
dialog.exec();
diff --git a/src/wizard/offline_tx_signing/PageOTS_ImportOffline.cpp b/src/wizard/offline_tx_signing/PageOTS_ImportOffline.cpp
index 6b7e5c2..90f880d 100644
--- a/src/wizard/offline_tx_signing/PageOTS_ImportOffline.cpp
+++ b/src/wizard/offline_tx_signing/PageOTS_ImportOffline.cpp
@@ -55,6 +55,20 @@ void PageOTS_ImportOffline::importFromStr(const std::string &data) {
return;
}
+ if (utx->txCount() == 0) {
+ m_scanWidget->pause();
+ Utils::showError(this, "Unable to load unsigned transaction", "Unsigned transaction set contains no transactions");
+ m_scanWidget->reset();
+ return;
+ }
+
+ if (utx->txCount() > 1) {
+ m_scanWidget->pause();
+ Utils::showError(this, "Unable to load unsigned transaction", "Unsigned transaction set contains more than one transaction");
+ m_scanWidget->reset();
+ return;
+ }
+
ui->frame_status->show();
ui->frame_status->setInfo(icons()->icon("confirmed.svg"), "Unsigned transaction imported successfully");
m_wizardFields->utx = utx;
diff --git a/src/wizard/offline_tx_signing/PageOTS_ImportSignedTx.cpp b/src/wizard/offline_tx_signing/PageOTS_ImportSignedTx.cpp
index f6102c6..3bead0c 100644
--- a/src/wizard/offline_tx_signing/PageOTS_ImportSignedTx.cpp
+++ b/src/wizard/offline_tx_signing/PageOTS_ImportSignedTx.cpp
@@ -26,6 +26,20 @@ void PageOTS_ImportSignedTx::importFromStr(const std::string &data) {
return;
}
+ if (tx->txCount() == 0) {
+ m_scanWidget->pause();
+ Utils::showError(this, "Unable to load signed transaction", "Signed transaction set contains no transactions");
+ m_scanWidget->reset();
+ return;
+ }
+
+ if (tx->txCount() > 1) {
+ m_scanWidget->pause();
+ Utils::showError(this, "Unable to load signed transaction", "Signed transaction set contains more than one transaction");
+ m_scanWidget->reset();
+ return;
+ }
+
m_wizardFields->tx = tx;
PageOTS_Import::onSuccess();
}
diff --git a/src/wizard/offline_tx_signing/PageOTS_ImportUnsignedTx.cpp b/src/wizard/offline_tx_signing/PageOTS_ImportUnsignedTx.cpp
index a489d70..c8fc6ba 100644
--- a/src/wizard/offline_tx_signing/PageOTS_ImportUnsignedTx.cpp
+++ b/src/wizard/offline_tx_signing/PageOTS_ImportUnsignedTx.cpp
@@ -27,6 +27,20 @@ void PageOTS_ImportUnsignedTx::importFromStr(const std::string &data) {
return;
}
+ if (utx->txCount() == 0) {
+ m_scanWidget->pause();
+ Utils::showError(this, "Unable to load unsigned transaction", "Unsigned transaction set contains no transactions");
+ m_scanWidget->reset();
+ return;
+ }
+
+ if (utx->txCount() > 1) {
+ m_scanWidget->pause();
+ Utils::showError(this, "Unable to load unsigned transaction", "Unsigned transaction set contains more than one transaction");
+ m_scanWidget->reset();
+ return;
+ }
+
m_wizardFields->utx = utx;
m_wizardFields->readyToSign = true;
PageOTS_Import::onSuccess();
Why this scored 45/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.