wallet rpc: fix isClosed() error number code (#183)
What changed, and why it matters
This commit fixes a bug in a Java library that talks to a Monero cryptocurrency wallet. The library checks whether the wallet connection is closed by looking for a specific error code returned by the wallet software. The old code looked for error code -8, but the wallet actually returns error code -13 in this situation, so the library could wrongly think an open wallet was closed. This is mostly a reliability/correctness issue rather than a direct security vulnerability, but it could cause applications to behave incorrectly or make wrong decisions about wallet state.
Review callers of isClosed() to confirm they handle a false 'not closed' result safely, and consider adding a fallback or logging when an unexpected RPC error code is seen. No urgent security patch appears required, but the fix should be included in the next release.
Security signals we found
Error-code mismatch in liveness/state detection
Potential false-negative closed-state reporting
Downstream state-dependent logic could be misled
Evidence from the diff
In MoneroWalletRpc.isClosed(), the method probes wallet liveness by calling getPrimaryAddress() and interpreting any MoneroRpcError. The previous check compared the RPC error code against -8, which is apparently not the code emitted when no wallet is loaded. The patch changes the comparison to -13 and keeps the ‘No wallet file’ message check. A misclassification means isClosed() could return false when the wallet is in fact closed/unloaded, or the surrounding catch logic could mask other errors. There is no direct exploit path visible in the diff, but downstream code that trusts isClosed() may act on stale state.
Changed components
src/main/java/monero/wallet/MoneroWalletRpc.javaMoneroWalletRpc.isClosed()Inspect captured patch +1 / −1
### src/main/java/monero/wallet/MoneroWalletRpc.java
@@ -1975,7 +1975,7 @@ public boolean isClosed() {
try {
this.getPrimaryAddress();
} catch (Exception e) {
- return e instanceof MoneroRpcError && Integer.valueOf(-8).equals(((MoneroRpcError) e).getCode()) && ((MoneroRpcError) e).getMessage().indexOf("No wallet file") > -1;
+ return e instanceof MoneroRpcError && Integer.valueOf(-13).equals(((MoneroRpcError) e).getCode()) && ((MoneroRpcError) e).getMessage().indexOf("No wallet file") > -1;
}
return false;
}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.