refuse descriptors that do not derive on the standard receive and change chains when importing a wallet or keystore, and warn of them in the descriptor editor
What changed, and why it matters
This commit tightens how Sparrow Wallet handles Bitcoin output descriptors imported from files, hardware wallets, QR codes, and the descriptor editor. It now rejects (or warns about) descriptors whose key paths don't follow the standard 'receive' and 'change' chains used by most wallets. This is a defensive change: non-standard derivation paths could previously be accepted silently, which might let a malicious or malformed descriptor make Sparrow derive addresses the user didn't expect, potentially hiding funds or tricking the user into sending to attacker-controlled addresses.
Users and integrators should upgrade to the release containing this commit. When importing wallets or keystores from external descriptors, verify that the descriptor uses standard receive/change derivation paths; if not, Sparrow will now refuse the import. Review the drongo submodule diff for the exact path-validation logic and ensure no import path bypasses verifyStandardChildDerivations().
Security signals we found
New validation of BIP32 derivation paths on all descriptor import paths
Rejection of descriptors with non-standard receive/change chains during wallet/keystore import
Warning (but not rejection) retained for descriptor editor where user can amend the descriptor
Potential address-derivation mismatch risk mitigated by enforcing standard /0/* and /1/* or /<0;1>/* patterns
Submodule update suggests underlying descriptor-parsing library changes implement the new checks
Evidence from the diff
The change adds calls to OutputDescriptor.verifyStandardChildDerivations() at every wallet/keystore import path (BIP129, Descriptor/PDF, Jade, Keystone, Specter DIY/Desktop, terminal watch-only dialog, keystore QR scan, settings descriptor QR scan). It also refactors SettingsController so descriptor editing/scanning uses a shared replaceWalletFromDescriptor() helper that warns via hasStandardChildDerivations() but still allows the operation. The drongo submodule bump likely contains the actual implementation of these new descriptor checks. The previous code only warned in the descriptor editor for a narrow set of path patterns; now the check is enforced on import and centralized.
Changed components
BIP129 keystore importDescriptor/PDF wallet importJade hardware wallet importKeystone singlesig hardware wallet importSpecter DIY hardware wallet importSpecter Desktop wallet importTerminal watch-only wallet importKeystore QR scan importSettings descriptor QR scan and descriptor editordrongo submodule (descriptor parsing library)Inspect captured patch +23 / −9
### drongo
@@ -1 +1 @@
-Subproject commit 99f978f5f434f1704fa5e2996b7daa671797d3b6
+Subproject commit 2cf12e7917ca8c0261c9b7629e241bd14ac99f9d
### src/main/java/com/sparrowwallet/sparrow/io/Bip129.java
@@ -175,6 +175,7 @@ private BufferedReader decryptImport(String password, BufferedReader streamReade
private Keystore getKeystore(String header, String token, String descriptor, String label, String signature) throws ImportException {
OutputDescriptor outputDescriptor = OutputDescriptor.getOutputDescriptor("sh(" + descriptor + ")");
+ outputDescriptor.verifyStandardChildDerivations();
Wallet wallet = outputDescriptor.toWallet();
Keystore keystore = wallet.getKeystores().get(0);
keystore.setLabel(label);
### src/main/java/com/sparrowwallet/sparrow/io/Descriptor.java
@@ -113,14 +113,17 @@ public Wallet importWallet(InputStream inputStream, String password) throws Impo
InputStream secondClone = new ByteArrayInputStream(baos.toByteArray());
try {
- return checkWallet(ensureKeyDerivations(PdfUtils.getOutputDescriptor(firstClone).toWallet()));
+ OutputDescriptor pdfDescriptor = PdfUtils.getOutputDescriptor(firstClone);
+ pdfDescriptor.verifyStandardChildDerivations();
+ return checkWallet(ensureKeyDerivations(pdfDescriptor.toWallet()));
} catch(Exception e) {
//ignore
}
List<String> paragraphs = getParagraphs(secondClone);
for(String paragraph : paragraphs) {
OutputDescriptor descriptor = OutputDescriptor.getOutputDescriptor(paragraph);
+ descriptor.verifyStandardChildDerivations();
return checkWallet(ensureKeyDerivations(descriptor.toWallet()));
}
### src/main/java/com/sparrowwallet/sparrow/io/Jade.java
@@ -42,6 +42,7 @@ public Keystore getKeystore(PolicyType policyType, ScriptType scriptType, InputS
+ ". Select " + scriptType.getDescription() + " in the options when using Export Xpub on your Jade, and export again.");
}
+ outputDescriptor.verifyStandardChildDerivations();
Wallet wallet = outputDescriptor.toWallet();
if(wallet.getKeystores().size() != 1) {
throw new IllegalArgumentException("Could not determine keystore from import");
### src/main/java/com/sparrowwallet/sparrow/io/KeystoneSinglesig.java
@@ -53,6 +53,7 @@ public Keystore getKeystore(PolicyType policyType, ScriptType scriptType, InputS
throw new IllegalArgumentException("Output descriptor describes a " + descriptor.getScriptType().getDescription() + " wallet");
}
+ descriptor.verifyStandardChildDerivations();
Wallet wallet = descriptor.toWallet();
Keystore keystore = wallet.getKeystores().getFirst();
keystore.setLabel(getName());
### src/main/java/com/sparrowwallet/sparrow/io/SpecterDIY.java
@@ -23,6 +23,7 @@ public Keystore getKeystore(PolicyType policyType, ScriptType scriptType, InputS
String text = CharStreams.toString(new InputStreamReader(inputStream, StandardCharsets.UTF_8));
String outputDesc = policyType == PolicyType.SINGLE_SP ? "sp(" + text + ")" : "sh(" + text + ")";
OutputDescriptor outputDescriptor = OutputDescriptor.getOutputDescriptor(outputDesc);
+ outputDescriptor.verifyStandardChildDerivations();
Wallet wallet = outputDescriptor.toWallet();
if(wallet.getKeystores().size() != 1) {
### src/main/java/com/sparrowwallet/sparrow/io/SpecterDesktop.java
@@ -95,6 +95,7 @@ public Wallet importWallet(InputStream inputStream, String password) throws Impo
if(specterWallet.descriptor != null) {
OutputDescriptor outputDescriptor = OutputDescriptor.getOutputDescriptor(specterWallet.descriptor);
+ outputDescriptor.verifyStandardChildDerivations();
Wallet wallet = outputDescriptor.toWallet();
wallet.setName(specterWallet.label);
### src/main/java/com/sparrowwallet/sparrow/terminal/wallet/WatchOnlyDialog.java
@@ -146,6 +146,7 @@ private List<Wallet> getWalletFromXpub(ExtendedKey xpub, ExtendedKey.Header head
private List<Wallet> getWalletFromOutputDescriptor(String text) {
OutputDescriptor outputDescriptor = OutputDescriptor.getOutputDescriptor(text);
+ outputDescriptor.verifyStandardChildDerivations();
Wallet wallet = outputDescriptor.toWallet();
wallet.setName(walletName);
if(wallet.getPolicyType() == PolicyType.SINGLE_SP && wallet.getBirthDate() == null && wallet.getBirthHeight() == null) {
### src/main/java/com/sparrowwallet/sparrow/wallet/KeystoreController.java
@@ -706,6 +706,7 @@ public void scanXpubQR(ActionEvent event) {
} else if(result.payload != null) {
try {
OutputDescriptor outputDescriptor = OutputDescriptor.getOutputDescriptor("sh(" + result.payload + ")");
+ outputDescriptor.verifyStandardChildDerivations();
Wallet wallet = outputDescriptor.toWallet();
Keystore keystore = wallet.getKeystores().get(0);
fingerprint.setText(keystore.getKeyDerivation().getMasterFingerprint());
### src/main/java/com/sparrowwallet/sparrow/wallet/SettingsController.java
@@ -366,7 +366,7 @@ public void scanDescriptorQR(ActionEvent event) {
if(optionalResult.isPresent()) {
QRScanDialog.Result result = optionalResult.get();
if(result.outputDescriptor != null) {
- rederiveAndReplaceWallet(result.outputDescriptor.toWallet());
+ replaceWalletFromDescriptor(result.outputDescriptor);
} else if(result.wallets != null) {
for(Wallet wallet : result.wallets) {
if(scriptType.getValue().equals(wallet.getScriptType()) && !wallet.getKeystores().isEmpty()) {
@@ -502,12 +502,9 @@ public void editDescriptor(ActionEvent event) {
}
}
String extKey = matcher.group(2);
- String childDerivationPath = matcher.group(3);
if(keyDerivationPath != null && ExtendedKey.Header.getHeaders(Network.get()).stream().anyMatch(header -> header.isPrivateKey() && extKey.startsWith(header.name()))) {
AppServices.showWarningDialog("Private extended key detected", "Sparrow will convert the provided private key to a public key for use in a watch only wallet.\n\nTo import a private key, use the Master Private Key option when creating a Software Wallet.");
- } else if(childDerivationPath != null && !(childDerivationPath.endsWith("/0/*") || childDerivationPath.endsWith("/1/*") || childDerivationPath.endsWith("/<0;1>/*"))) {
- AppServices.showWarningDialog("Non standard child derivation detected", "Sparrow does not support non-BIP32 wallets without standard receive and change chains.\n\nThe provided descriptor will be amended if necessary.");
}
}
@@ -517,14 +514,21 @@ public void editDescriptor(ActionEvent event) {
private void setDescriptorText(String text) {
try {
- OutputDescriptor editedOutputDescriptor = OutputDescriptor.getOutputDescriptor(text.trim().replace("\\", ""));
- Wallet editedWallet = editedOutputDescriptor.toWallet();
- rederiveAndReplaceWallet(editedWallet);
+ replaceWalletFromDescriptor(OutputDescriptor.getOutputDescriptor(text.trim().replace("\\", "")));
} catch(Exception e) {
AppServices.showErrorDialog("Invalid output descriptor", e.getMessage());
}
}
+ private void replaceWalletFromDescriptor(OutputDescriptor outputDescriptor) {
+ if(!outputDescriptor.hasStandardChildDerivations()) {
+ AppServices.showWarningDialog("Non standard child derivation detected",
+ "Sparrow does not support non-BIP32 wallets without standard receive and change chains.\n\nThe provided descriptor will be amended if necessary.");
+ }
+
+ rederiveAndReplaceWallet(outputDescriptor.toWallet());
+ }
+
private void rederiveAndReplaceWallet(Wallet editedWallet) {
if(!walletForm.getWallet().isMasterWallet() && (editedWallet.getPolicyType() != walletForm.getMasterWallet().getPolicyType() || editedWallet.getScriptType() != walletForm.getMasterWallet().getScriptType())) {
AppServices.showErrorDialog("Policy or Script Type Mismatch", "The provided output descriptor does not match the policy or script type of this wallet.");Why this scored 46/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.