stop displaying full stacktrade on zec sending failure
What changed, and why it matters
This commit changes how Zcash transaction errors are shown to users. Previously, when sending or creating a Zcash transaction failed, the app could display a long internal Rust programming error (a 'stack backtrace'). Now it catches those errors and shows a shorter, user-friendly message instead. This is mainly a user-experience and information-disclosure cleanup, not a fix for a code-execution vulnerability.
Treat as a low-severity hardening improvement. No urgent action required, but verify that the wrapped exception messages still contain enough detail for support diagnostics and that `printV` logs are not exposed to unprivileged users.
Security signals we found
Information disclosure reduction: raw Rust stack traces no longer shown to users
Error-message sanitization: long backtraces replaced by compact CakeException messages
No cryptographic, authorization, or memory-safety changes observed
No input validation or transaction-logic changes observed
Evidence from the diff
The patch introduces a helper withCompactRustErrors in cw_zcash/lib/src/util/exceptions.dart that intercepts exceptions whose string representation contains ‘Stack backtrace:’. It logs the full error via printV, then rethrows a wrapped CakeException containing only the message before the backtrace. The helper is applied to _commit, _commitScannedUr, _createTransaction, and _createShieldingTransaction. This prevents raw Rust stack traces from surfacing in user-facing error dialogs, reducing information disclosure and improving error readability.
Changed components
cw_zcash/lib/src/pending_zcash_transaction.dartcw_zcash/lib/src/util/exceptions.dartcw_zcash/lib/src/zcash_wallet.dartInspect captured patch +32 / −5
### cw_zcash/lib/src/pending_zcash_transaction.dart
@@ -2,9 +2,11 @@ import 'dart:async';
import 'package:cw_core/amount/money.dart';
import 'package:cw_core/exceptions.dart';
+import 'package:cw_core/exceptions/cake_exception.dart';
import 'package:cw_core/pending_transaction.dart';
import 'package:cw_core/utils/print_verbose.dart';
import 'package:cw_zcash/cw_zcash.dart';
+import 'package:cw_zcash/src/util/exceptions.dart';
import 'package:zkool/src/rust/api/pay.dart' as zkool_pay;
class PendingZcashTransaction with PendingTransaction {
@@ -41,7 +43,9 @@ class PendingZcashTransaction with PendingTransaction {
final Money fee;
@override
- Future<void> commit() async {
+ Future<void> commit() => withCompactRustErrors(_commit, TransactionSendingException.new);
+
+ Future<void> _commit() async {
await ZcashWalletBase.runWithCoin(
accountId: zcashWallet.accountId,
func: (coin) async {
@@ -81,7 +85,8 @@ class PendingZcashTransaction with PendingTransaction {
@override
Future<Map<String, String>> commitUR() async {
- zcashWallet.onCommitAirgapUr = _commitScannedUr;
+ zcashWallet.onCommitAirgapUr = (raw) =>
+ withCompactRustErrors(() => _commitScannedUr(raw), TransactionSendingException.new);
return {'Cupcake': encodeZcashPcztUr(txPlan.pczt).join('\n')};
}
### cw_zcash/lib/src/util/exceptions.dart
@@ -1,6 +1,7 @@
import "package:cw_core/exceptions/cake_exception.dart";
+import "package:cw_core/utils/print_verbose.dart";
class WalletLockedException extends CakeException {
const WalletLockedException() : super("Zcash wallet locked! Please contact support");
@@ -20,4 +21,19 @@ class AddressRotationException extends CakeException {
class MigrationException extends CakeException {
const MigrationException(super.message);
-}
\ No newline at end of file
+}
+
+Future<T> withCompactRustErrors<T>(
+ final Future<T> Function() body,
+ final CakeException Function(String message) wrap,
+) async {
+ try {
+ return await body();
+ } catch (e, s) {
+ if (!e.toString().contains("Stack backtrace:")) {
+ rethrow;
+ }
+ printV(e);
+ Error.throwWithStackTrace(wrap(e.toString().split("Stack backtrace:").first.trim()), s);
+ }
+}
### cw_zcash/lib/src/zcash_wallet.dart
@@ -450,7 +450,10 @@ abstract class ZcashWalletBase
@override
Future<PendingTransaction> createTransaction(final Object credentials) =>
- _createTransaction(credentials);
+ withCompactRustErrors(
+ () => _createTransaction(credentials),
+ TransactionGenerationException.new,
+ );
Future<PendingTransaction> _createTransaction(
final Object credentials, {
@@ -1302,7 +1305,10 @@ abstract class ZcashWalletBase
bool hasOrchardMigratableBalance() => _orchardMigratable;
- Future<PendingTransaction?> createShieldingTransaction() async {
+ Future<PendingTransaction?> createShieldingTransaction() =>
+ withCompactRustErrors(_createShieldingTransaction, TransactionGenerationException.new);
+
+ Future<PendingTransaction?> _createShieldingTransaction() async {
final txPlan = await runWithCoin(
accountId: accountId,
func: (coin) async {Why this scored 24/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.