hold rates, version and currency requests and refuse auth47 and lnurl-auth logins while internal tor is starting
What changed, and why it matters
This commit fixes a privacy and security issue in Sparrow Wallet where certain network requests and authentication actions could run before the built-in Tor proxy was ready. Without the fix, those requests could bypass Tor and expose the user's real IP address or real network identity. The patch pauses exchange-rate checks, version checks, and currency list fetches, and blocks Auth47 and LNURL-auth logins until Tor has finished starting.
Users who rely on Tor in Sparrow Wallet should upgrade to a release containing this commit. Reviewers should verify that no other Tor-required request paths are missing the isWaitingForTor() guard and that the services are correctly restarted once Tor is running.
Security signals we found
Requests that should transit Tor could be sent over a direct connection during Tor startup
Auth47 and LNURL-auth authentication could be performed without Tor, deanonymizing the user
Exchange-rate, version, and currency requests could leak real IP address and wallet usage timing
Proxy failure handling now cancels services that must use Tor before restarting it
Evidence from the diff
The change introduces AppServices.isWaitingForTor(), which is true when the configuration requires internal Tor and the Tor process is not yet running. It then guards ratesService, versionCheckService, and updateCurrencies() from starting while Tor is still starting, and refuses openAuth47Uri() and openLnurlAuthUri() with an error dialog in that state. It also cancels the rates and version services when a proxy failure triggers an internal Tor restart, so they do not continue over a direct connection.
Changed components
AppServices.java: Tor/proxy state helpers and request schedulingAppServices.java: Auth47 URI handlingAppServices.java: LNURL-auth URI handlingAppServices.java: Rates service and version check service lifecycleGeneralSettingsController.java: Currency list update logicInspect captured patch +25 / −3
### src/main/java/com/sparrowwallet/sparrow/AppServices.java
@@ -388,6 +388,9 @@ private ElectrumServer.ConnectionService createConnectionService() {
if(failEvent.getSource().getException() instanceof ProxyServerException && Config.get().isUseProxy() && Config.get().isAutoSwitchProxy() && Config.get().requiresTor()) {
Config.get().setUseProxy(false);
+ //These are started again once Tor is running
+ ratesService.cancel();
+ versionCheckService.cancel();
Platform.runLater(() -> restartService(torService));
return;
}
@@ -572,6 +575,11 @@ public static boolean isTorRunning() {
return Tor.getDefault() != null;
}
+ //Until internal Tor is running there is no proxy for requests that must use it, and these would otherwise be made directly
+ public static boolean isWaitingForTor() {
+ return Config.get().requiresInternalTor() && !isTorRunning();
+ }
+
public static boolean isUsingProxy() {
return isTorRunning() || Config.get().isUseProxy();
}
@@ -1276,6 +1284,11 @@ private static void openBitcoinUri(URI uri) {
}
private static void openAuth47Uri(URI uri) {
+ if(isWaitingForTor()) {
+ showErrorDialog("Tor Not Running", "Authentication must be done over Tor, which is not yet running. Try again once Sparrow is connected.");
+ return;
+ }
+
try {
Auth47 auth47 = new Auth47(uri);
List<ScriptType> scriptTypes = PaymentCode.SEGWIT_SCRIPT_TYPES;
@@ -1297,6 +1310,11 @@ private static void openAuth47Uri(URI uri) {
}
private static void openLnurlAuthUri(URI uri) {
+ if(isWaitingForTor()) {
+ showErrorDialog("Tor Not Running", "Authentication must be done over Tor, which is not yet running. Try again once Sparrow is connected.");
+ return;
+ }
+
try {
LnurlAuth lnurlAuth = new LnurlAuth(uri);
List<ScriptType> scriptTypes = ScriptType.getAddressableScriptTypes(PolicyType.SINGLE_HD);
@@ -1537,7 +1555,9 @@ public void fiatCurrencySelected(FiatCurrencySelectedEvent event) {
if(Config.get().getMode() != Mode.OFFLINE && event.getExchangeSource() != ExchangeSource.NONE) {
ratesService = createRatesService(event.getExchangeSource(), event.getCurrency());
- ratesService.start();
+ if(!isWaitingForTor()) {
+ ratesService.start();
+ }
}
}
}
@@ -1553,7 +1573,9 @@ public void versionCheckStatus(VersionCheckStatusEvent event) {
if(Config.get().getMode() != Mode.OFFLINE && event.isEnabled() && Network.get() == Network.MAINNET) {
versionCheckService = createVersionCheckService();
- versionCheckService.start();
+ if(!isWaitingForTor()) {
+ versionCheckService.start();
+ }
}
}
### src/main/java/com/sparrowwallet/sparrow/settings/GeneralSettingsController.java
@@ -208,7 +208,7 @@ private ObservableList<Server> getBlockExplorerList() {
}
private void updateCurrencies(ExchangeSource exchangeSource) {
- if(Config.get().getMode() == Mode.OFFLINE) {
+ if(Config.get().getMode() == Mode.OFFLINE || AppServices.isWaitingForTor()) {
Currency configCurrency = Config.get().getFiatCurrency();
updateCurrencies(configCurrency == null || exchangeSource == ExchangeSource.NONE ? List.of() : List.of(configCurrency));
return;Why this scored 64/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.