Repository navigation
net: Warn when Tor onion service lacks a dedicated onion bind - #34892
HouseOfHufflepuff wants to merge 1 commit into
Conversation
|
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. Code Coverage & BenchmarksFor details see: https://corecheck.dev/bitcoin/bitcoin/pulls/34892. ReviewsSee the guideline and AI policy for information on the review process.
If your review is incorrectly listed, please copy-paste ConflictsReviewers, this pull request conflicts with the following ones:
If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first. |
|
Looks like the functional test You can fix it by modifying this bit of code to looks like this |
|
Thanks @kevkevinpal! Good catch — applied the fix to |
|
Please squash your commits according to https://github.com/bitcoin/bitcoin/blob/master/CONTRIBUTING.md#squashing-commits Also, the test plan is clearly wrong. Was this LLM generated? What are the steps to test this? What is the output before and after the changes here? |
|
Sorry about that @maflcko — you're right, the test plan was inadequate and there were unrelated changes that shouldn't have been in the branch. I've squashed into a single commit, removed the unrelated changes, and updated the PR description with actual before/after output. Should be ready for another look when you have time. |
97bcdad to
bfb2401
Compare
|
I think it would be good to add a test asserting that this warning gets logged. In addition to modifying the existing test that was failing. |
|
You'll have to run the tests locally before pushing to CI |
c33d92a to
2e63783
Compare
|
@maflcko Apologies for the messy state earlier — commits are squashed, unrelated changes removed, and tests verified locally before pushing. Lesson learned on the workflow. Ready for re-review whenever you have time. |
|
@kevkevinpal Thanks for the proxy test catch and the suggestion to add a warning assertion — both are addressed now. CI is passing clean. Would appreciate another look when you have a moment. |
naiyoma
left a comment
There was a problem hiding this comment.
I’m not sure about this approach. I think the right direction would be to try to get the count right. I’ve explained what I think the two options might be -> #33458 (comment)
I was wrong about the alternative approaches I suggested. I don't think we can get the correct count. This approach is fine. |
| @@ -436,6 +436,17 @@ def networks_dict(d): | |||
|
|
|||
| self.log.info("Test passing -onlynet=onion without -proxy or -onion but with -listenonion=1 is ok") | |||
| self.start_node(1, extra_args=["-onlynet=onion", "-listenonion=1"]) | |||
| self.stop_node(1, expected_stderr="Warning: The Tor onion service is being directed to a -bind address without a dedicated onion socket (-bind=<addr>=onion). Incoming Tor connections will not be identified as onion connections.") | |||
There was a problem hiding this comment.
Nit: IMO this test would be better placed in feature_bind_extra.py rather than in this file.
feature_bind_extra.py also sets bind_to_localhost_only = False, meaning we can explicitly control -bind configuration and not rely on the default.
I initially found it confusing why the test was passing, and then I realized that by default, bind_to_localhost_only is true.
There was a problem hiding this comment.
Done, moved and using explicit bind.
This is a good suggestion from the issue have you considered implementing it? |
9a2fd75 to
f23b35a
Compare
|
Thanks for the review @naiyoma! Moved the warning tests from feature_proxy.py to feature_bind_extra.py where bind_to_localhost_only = False gives us explicit control over -bind configuration. The tests now pass explicit -bind args so it's clear why the warning fires (or doesn't). The -onlynet=onion -listenonion=1 test stays in feature_proxy.py since it's testing the onlynet behavior, and just handles the warning as expected stderr. Re: showing "?" or "-" instead of "0" in -netinfo — that's a good idea from the original issue, but I think it's better suited as a follow-up PR since it touches different code (-netinfo output formatting in bitcoin-cli). Happy to open an issue and work if you would like. Happy to do here as well but wanted to check. |
dc708ab to
716812b
Compare
perhaps the day you pushed these changes, github had run into reliability issues thus returning a timeout. so i think a small hack you can use to re-trigger the CI is to amend the last commit: git commit --amend --no-edit
git push --force-with-leaseit won’t add extra commits, so no need to squash later. if it fails twice in the same way, stop retrying and treat it as a real issue in the test or environment. |
716812b to
7025bf3
Compare
Thank you. I re-ran and CI is green. |
| @@ -107,6 +108,7 @@ def _get_response(self, command): | |||
| class TorControlTest(BitcoinTestFramework): | |||
| def set_test_params(self): | |||
| self.num_nodes = 1 | |||
| self.extra_args = [[f"-bind=127.0.0.1:{tor_port(0)}=onion"]] | |||
There was a problem hiding this comment.
i think this extra_args property can be removed in favour of the one on line 123. this is because it has no clear effect on the tests (actually they pass perfectly, even without it)
There was a problem hiding this comment.
Removed, you're right it's redundant.
| @@ -436,7 +436,7 @@ def networks_dict(d): | |||
|
|
|||
| self.log.info("Test passing -onlynet=onion without -proxy or -onion but with -listenonion=1 is ok") | |||
| self.start_node(1, extra_args=["-onlynet=onion", "-listenonion=1"]) | |||
There was a problem hiding this comment.
i think we're not very interested in testing for the warning's presence here as much as we do in feature_bind_extra.py. for that reason, we can pass an explicit -bind here in order to avoid triggering the warning's condition introduced by the PR's init.cpp
| self.start_node(1, extra_args=["-onlynet=onion", "-listenonion=1"]) | |
| self.start_node(1, extra_args=["-onlynet=onion", "-listenonion=1", f"-bind=127.0.0.1:{tor_port(1)}=onion"]) |
i think this will fulfill @naiyoma's nit and also prevents tight coupling in the tests.
There was a problem hiding this comment.
Fixed, passing explicit bind now.
| @@ -534,6 +534,10 @@ def set_tx_returner_and_other(): | |||
| assert_raises_rpc_error(-1, "none of the Tor or I2P networks is reachable", | |||
| tx_originator.sendrawtransaction, hexstring=txs[0]["hex"], maxfeerate=0.1) | |||
|
|
|||
| # Restart node 0 with original args so that cleanup does not fail due to | |||
| # the warning about missing dedicated onion bind on stderr. | |||
| self.restart_node(0, expected_stderr="Warning: The Tor onion service is being directed to a -bind address without a dedicated onion socket (-bind=<addr>=onion). Incoming Tor connections will not be identified as onion connections.") | |||
There was a problem hiding this comment.
Fixed, passing explicit bind now.
winterrdog
left a comment
There was a problem hiding this comment.
@HouseOfHufflepuff
tested and left some review comments for you.
7025bf3 to
cc1bf1d
Compare
Thank you. I have addressed the comments with the suggested implementation. |
|
Re-ACK cc1bf1d |
|
@naiyoma can you take another look here? |
|
Sorry, I was AFK. I'll re-review soon |
|
i think you will need to edit the commit message and remove Anthropic's Claude as a co-author. a recent AI policy was passed saying that LLMs are just tools, so they should not be credited as co-authors if there were other contributors, they can be added as co-authors; otherwise, the also, i think the commit message could be trimmed down. right now it repeats the PR description almost line-for-line, and since the merge script folds the full PR description into the merge commit anyway, having both means the same explanation ends up duplicated in permanent history. a shorter commit message focused on the "what/why" would be enough. sth like (you are completely free to modify it into what you want): |
When -bind is specified without a dedicated -bind=<addr>=onion, the auto-created Tor hidden service routes incoming connections to the regular bind address, making it impossible to distinguish incoming Tor connections from regular ones (-netinfo reports 0 onion connections even when they exist). Warn at startup when listenonion is set but no dedicated onion bind is configured, so users can add -bind=127.0.0.1:8334=onion for accurate connection tracking. Update functional tests to cover the new warning and to pass an explicit onion bind where the warning would otherwise be spurious. Fixes bitcoin#33458
cc1bf1d to
4736431
Compare
I have removed this. Thank you. |
There was a problem hiding this comment.
reACK 4736431
ZERO code changes were made between this commit and the previous one. only the commit message was edited to cut back on the verbosity thus changing the commit hash as a result
|
ACK 4736431 |
|
The warning seems like an improvement over
Sounds much safer to me to just refuse to start with a config like
If the onion service is configured statically from |
|
Closing in favor of #36170, which implements the hard-error approach suggested by @vasild and carries forward the detection logic and tests from here (credited as coauthor). Thanks everyone for the reviews on this one — @naiyoma, @kevkevinpal, @winterrdog, @maflcko, @jpk68. |
Summary
When
-bindis specified without a dedicated onion socket (-bind=<addr>=onion) but-listenonionis enabled, the auto-created Tor hidden service routes incoming connections to the regular bind address. This makes it impossible to distinguish incoming Tor connections from regular IPv4 connections, causing-netinfoto report 0 onion connections even when they exist.This adds a startup warning to alert users so they can add
-bind=127.0.0.1:8334=onionfor accurate connection tracking.Fixes #33458
Test plan
Start bitcoind with
-bindbut without a dedicated onion bind:Before this change: No warning is emitted. Users have no indication that incoming Tor connections will be misidentified.
After this change: A warning is printed at startup:
The warning does not appear when a dedicated onion bind is provided:
Functional test
feature_proxy.pyupdated to expect the new warning.