validate bip129 header on import, and fix importing unencrypted bsms files with open wallet
What changed, and why it matters
This commit fixes two wallet-import bugs in Sparrow. First, it adds a missing check that a file being imported as a BIP-129/BSMS backup actually starts with the expected 'BSMS' header, which could previously cause the app to misread an unrelated or malformed file. Second, it adds BIP-129 to the list of importers tried when a wallet is already open, so unencrypted BSMS files can be imported in that situation. The change is defensive and reduces the chance of importing the wrong data, but it is a small, partial patch rather than a full security overhaul.
Users importing BSMS files should upgrade to the version containing this commit. Review whether other wallet importers perform equivalent header/magic validation, and consider adding tests for malformed file handling across all importers.
Security signals we found
Input validation added for file format header
Missing importer registration could have caused fallback to less appropriate parsers
Potential silent parsing of malformed/unexpected file content reduced
Evidence from the diff
The diff modifies AppController.java to include Bip129 in the walletImporters list used by attemptImportWallet(File, SecureString), enabling BIP-129/BSMS import when a wallet is already open. It also modifies Bip129.java to validate that the first line of an imported file starts with ‘BSMS’ before parsing descriptor, paths, and address lines. Previously, a null or non-BSMS first line could be silently accepted, leading to parsing failures or potentially misleading import behavior. The fix is straightforward input validation and importer registration.
Changed components
src/main/java/com/sparrowwallet/sparrow/AppController.javasrc/main/java/com/sparrowwallet/sparrow/io/Bip129.javaBIP-129/BSMS wallet import featureInspect captured patch +5 / −0
diff --git a/src/main/java/com/sparrowwallet/sparrow/AppController.java b/src/main/java/com/sparrowwallet/sparrow/AppController.java
index 7822764..191ce5b 100644
--- a/src/main/java/com/sparrowwallet/sparrow/AppController.java
+++ b/src/main/java/com/sparrowwallet/sparrow/AppController.java
@@ -1287,6 +1287,7 @@ public class AppController implements Initializable {
private boolean attemptImportWallet(File file, SecureString password) {
List<WalletImport> walletImporters = List.of(new ColdcardSinglesig(), new ColdcardMultisig(),
+ new Bip129(),
new Electrum(),
new SpecterDesktop(),
new Descriptor(),
diff --git a/src/main/java/com/sparrowwallet/sparrow/io/Bip129.java b/src/main/java/com/sparrowwallet/sparrow/io/Bip129.java
index 4e20427..cae0bce 100644
--- a/src/main/java/com/sparrowwallet/sparrow/io/Bip129.java
+++ b/src/main/java/com/sparrowwallet/sparrow/io/Bip129.java
@@ -235,6 +235,10 @@ public class Bip129 implements KeystoreFileExport, KeystoreFileImport, WalletExp
}
String header = reader.readLine();
+ if(header == null || !header.startsWith("BSMS")) {
+ throw new ImportException("Not a BSMS file");
+ }
+
String descriptor = reader.readLine();
String paths = reader.readLine();
String address = reader.readLine();
Why this scored 35/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.