escape the wallet name when using it to name the database update thread
What changed, and why it matters
This commit makes two small changes to how Sparrow Wallet handles its internal database. The first and more prominent change escapes percent signs in wallet names before using them as Java thread names, which prevents a harmless formatting quirk in logging/monitoring tools. The second change is a code-style refactor around how database metadata types are assigned, with no obvious security effect. There is no indication this fixes an exploitable vulnerability.
No urgent action required. Treat as routine hardening. If reviewing, confirm that wallet names cannot influence other system identifiers and that the thread name is not logged in contexts where further format-string interpretation occurs.
Security signals we found
Input sanitization: wallet name percent-sign escaping before use in thread naming pattern
Thread factory naming pattern injection hardening
No evidence of memory safety, cryptographic, or authorization issues in the diff
Evidence from the diff
In DbPersistence.java, the wallet name is now passed through .replace(“%”, “%%”) before being embedded in the BasicThreadFactory namingPattern. This is a defensive measure against String.format-style interpretation of percent characters in thread names, which could cause formatting errors or unexpected display behavior when the thread name is later used in formatted output. The second hunk refactors MVMap.Builder construction to use explicit local variables and suppress an unchecked-cast warning; it appears functionally equivalent to the prior code and unrelated to the thread-name change. No security boundary is crossed, no privilege escalation, and no data exposure is evident from the diff.
Changed components
src/main/java/com/sparrowwallet/sparrow/io/db/DbPersistence.javaWallet database update executor thread namingInspect captured patch +9 / −4
### src/main/java/com/sparrowwallet/sparrow/io/db/DbPersistence.java
@@ -289,7 +289,7 @@ public void updateWallet(Storage storage, Wallet wallet, ECKey encryptionPubKey)
private synchronized void createUpdateExecutor(Wallet masterWallet) {
if(updateExecutor == null) {
- BasicThreadFactory factory = BasicThreadFactory.builder().namingPattern(masterWallet.getFullName() + "-dbupdater").daemon(true).priority(Thread.NORM_PRIORITY).build();
+ BasicThreadFactory factory = BasicThreadFactory.builder().namingPattern(masterWallet.getFullName().replace("%", "%%") + "-dbupdater").daemon(true).priority(Thread.NORM_PRIORITY).build();
updateExecutor = Executors.newSingleThreadExecutor(factory);
}
}
@@ -553,13 +553,18 @@ private void validateStore(File walletFile, String filePassword) throws StorageE
}
}
- MVMap.Builder<Long, VersionedValue<?>> metaTableBuilder = new MVMap.Builder<>();
+ DataType<?> keyType;
+ DataType<?> valueType;
if(undoRecords != null && undoRecords.mapIds.contains(metaTableId)) {
- metaTableBuilder.keyType((DataType)undoRecords.getKeyType(metaTableId)).valueType((DataType)undoRecords.getValueType(metaTableId));
+ keyType = undoRecords.getKeyType(metaTableId);
+ valueType = undoRecords.getValueType(metaTableId);
} else {
RowFactory rowFactory = RowFactory.getDefaultRowFactory().createRowFactory(null, CompareMode.getInstance(null, 0), null, H2_META_TABLE_COLUMNS, null, false);
- metaTableBuilder.keyType(LongDataType.INSTANCE).valueType((DataType)new VersionedValueType<>(rowFactory.getRowDataType()));
+ keyType = LongDataType.INSTANCE;
+ valueType = new VersionedValueType<>(rowFactory.getRowDataType());
}
+ @SuppressWarnings("unchecked")
+ MVMap.Builder<Long, VersionedValue<?>> metaTableBuilder = new MVMap.Builder<Long, VersionedValue<?>>().keyType((DataType<Long>)keyType).valueType((DataType<VersionedValue<?>>)valueType);
MVMap<Long, VersionedValue<?>> metaTable = store.openMap(H2_META_TABLE_MAP, metaTableBuilder);
List<String> statements = new ArrayList<>();
Cursor<Long, VersionedValue<?>> cursor = metaTable.cursor(null);Why this scored 17/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.