config: apply --torisolation to --proxy without credentials
What changed, and why it matters
This commit fixes a configuration bug in btcd, a Bitcoin node implementation. When a user enabled Tor stream isolation with --torisolation and used a proxy without a username/password, the isolation was silently not applied. The fix makes --torisolation work as expected regardless of whether proxy credentials are set, except in 'bridge mode' where a separate onion proxy is configured. The practical effect is that affected users' connections through Tor were not being isolated as they believed, potentially reducing their privacy.
Users running btcd with --proxy and --torisolation but without --proxyuser/--proxypass should upgrade to this commit or a release containing it, because their Tor stream isolation was not active. Operators relying on isolation for privacy should verify their configuration after upgrading. No immediate active-exploitation response is needed; this is a privacy-hardening fix.
Security signals we found
Privacy configuration silently ignored
Tor stream isolation bypass
User expectation mismatch between flags and behavior
Regression introduced by prior refactor
Evidence from the diff
The bug was in loadConfig() in config.go. The original code only set torIsolation=true when cfg.TorIsolation was true, no onion proxy was set, AND either ProxyUser or ProxyPass was non-empty. This meant a plain –proxy=127.0.0.1:9050 –torisolation silently skipped stream isolation. The credentials were only intended to decide whether to print a warning that they would be overridden. A 2016 refactor accidentally merged the credential check into the isolation condition. The patch introduces proxyTorIsolation(torIsolation, onionProxy) which returns true whenever TorIsolation is set and OnionProxy is empty. The credential check is now only used to emit the warning. A unit test is added covering isolation enabled, isolation disabled, and bridge mode.
Changed components
btcd config loading (config.go)Tor proxy integration--torisolation and --proxy CLI optionsInspect captured patch +41 / −3
### config.go
@@ -104,6 +104,13 @@ func validateMaxPeers(maxPeers int) error {
return nil
}
+// proxyTorIsolation returns whether connections through --proxy use Tor stream
+// isolation. When --onion is set too, --proxy isn't the Tor proxy and the
+// onion proxy is isolated instead.
+func proxyTorIsolation(torIsolation bool, onionProxy string) bool {
+ return torIsolation && onionProxy == ""
+}
+
// config defines the configuration options for btcd.
//
// See loadConfig for details on the configuration load process.
@@ -1079,11 +1086,12 @@ func loadConfig() (*config, []string, error) {
// Tor isolation flag means proxy credentials will be overridden
// unless there is also an onion proxy configured in which case
// that one will be overridden.
- torIsolation := false
- if cfg.TorIsolation && cfg.OnionProxy == "" &&
+ torIsolation := proxyTorIsolation(
+ cfg.TorIsolation, cfg.OnionProxy,
+ )
+ if torIsolation &&
(cfg.ProxyUser != "" || cfg.ProxyPass != "") {
- torIsolation = true
fmt.Fprintln(os.Stderr, "Tor isolation set -- "+
"overriding specified proxy user credentials")
}
### config_test.go
@@ -32,6 +32,36 @@ func TestValidateMaxPeers(t *testing.T) {
}
}
+// TestProxyTorIsolation checks when --torisolation applies to --proxy: always,
+// unless --onion is set too, in which case it applies to the onion proxy.
+func TestProxyTorIsolation(t *testing.T) {
+ tests := []struct {
+ name string
+ torIsolation bool
+ onionProxy string
+ want bool
+ }{
+ {name: "isolation", torIsolation: true, want: true},
+ {name: "no isolation"},
+ {
+ name: "bridge mode",
+ torIsolation: true,
+ onionProxy: "127.0.0.1:9050",
+ },
+ }
+
+ for _, test := range tests {
+ t.Run(test.name, func(t *testing.T) {
+ got := proxyTorIsolation(
+ test.torIsolation, test.onionProxy,
+ )
+ if got != test.want {
+ t.Fatalf("got %v, want %v", got, test.want)
+ }
+ })
+ }
+}
+
var (
rpcuserRegexp = regexp.MustCompile("(?m)^rpcuser=.+$")
rpcpassRegexp = regexp.MustCompile("(?m)^rpcpass=.+$")Why this scored 49/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.