net: ignore privacy network peer's view of our address #36757

pull stratospher wants to merge 2 commits into bitcoin:master from stratospher:2026-10-dont-use-addrMe-tori2p changing 2 files +39 −1
  1. stratospher commented at 2:56 PM on November 4, 2026: contributor

    privacy networks set addrMe ("IP address peer thinks I am") in the VERSION message as all zeroes. this PR ensures we ignore it when processing VERSION message.

    this fixes a fingerprint which makes it possible to correlate clearnet and privacy network IPs but it requires some not so easy preconditions:

    1. we need to choose this adversarial tor/i2p peer to make an outbound connection to from our addrman
    2. we need to be using a unique enough port. this would become easier in a future if we ever support random ports.

    h/t to Loupe and instagibbs for finding this fingerprint!

  2. in src/net.cpp:240 in fb178b2374 outdated
     235 | @@ -236,7 +236,9 @@ static int GetnScore(const CService& addr)
     236 |  [[nodiscard]] static bool IsPeerAddrLocalGood(CNode *pnode)
     237 |  {
     238 |      CService addrLocal = pnode->GetAddrLocal();
     239 | -    return fDiscover && pnode->addr.IsRoutable() && addrLocal.IsRoutable() &&
     240 | +    // A peer on a privacy network cannot see our address, so its view of us is never useful.
     241 | +    return fDiscover && !pnode->IsConnectedThroughPrivacyNet() &&
    


    0xB10C commented at 4:07 PM on November 4, 2026:

    CJDNS is not a privacy network and does not return true for IsConnectedThroughPrivacyNet(). Does CJDNS need to be treated similarly?


    mzumsande commented at 6:49 PM on November 4, 2026:

    Wouldn't the port in the replaced address usually be the port of our CJDNS address, which the CJDNS peer already knows anyway from our normal self-advertisement?


    jonatack commented at 9:32 PM on November 4, 2026:

    Yes, CJDNS is an end-to-end encrypted IPv6 overlay with a friend-of-a-friend mesh topology and intermediate routers can see the endpoints. A CJDNS peer already knows the node's CJDNS address (and typically the port) from ordinary self-advertisement on the CJDNS network.


    stratospher commented at 10:33 PM on November 5, 2026:

    good question. if I make an outbound connection to a cjdns peer running core, the cjdns peer will send all zeroes in addrMe in VERSION message (since it's not addr v1 compatible). so logically we could just ignore it like we do for tor/i2p.

    but I don't think there's a privacy risk here since cjdns isn't an anonymity network like tor/i2p.

    we also send cjdns self advertisements (and not ipv4/ipv6) to our cjdns peers and it would be our cjdns port getting sent as mentioned above. (unless running a strange bitcoin.conf ex: -cjdnsreachable -externalip=<ipv4-address> in which case you could get the full ip address itself and not just port. but this is a misconfiguration scenario.)

  3. mzumsande commented at 6:48 PM on November 4, 2026: contributor

    Concept ACK

  4. darosior commented at 8:02 PM on November 4, 2026: member

    Concept ACK

  5. jonatack commented at 9:33 PM on November 4, 2026: member

    Approach ACK, not sure what the CI issue was

  6. DrahtBot commented at 10:33 PM on November 5, 2026: contributor

    <!--e57a25ab6845829454e8d69fc972939a-->

    The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

    <!--006a51241073e994b41acfe9ec718e94-->

    External sites

    <!--021abf342d371248e50ceaed478a90ca-->

    Reviews

    See the guideline and AI policy for information on the review process.

    Type Reviewers
    ACK mzumsande, danielabrozzoni, sedited
    Concept ACK darosior
    Approach ACK jonatack, w0xlt

    If your review is incorrectly listed, please copy-paste <code>&lt;!--meta-tag:bot-skip--&gt;</code> into the comment that the bot should ignore.

    <!--174a7506f384e20aa4161008e828411d-->

    Conflicts

    Reviewers, this pull request conflicts with the following ones:

    • #35578 <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/35578.svg"></sub> (net: don’t self advertise tor exit node ip addresses in outbound connections by stratospher)

    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.

    <!--5faf32d7da4f0f540f40219e4f7537a3-->

  7. w0xlt commented at 12:01 AM on November 6, 2026: contributor

    Approach ACK

  8. in src/net.cpp:239 in fb178b2374
     235 | @@ -236,7 +236,9 @@ static int GetnScore(const CService& addr)
     236 |  [[nodiscard]] static bool IsPeerAddrLocalGood(CNode *pnode)
     237 |  {
     238 |      CService addrLocal = pnode->GetAddrLocal();
     239 | -    return fDiscover && pnode->addr.IsRoutable() && addrLocal.IsRoutable() &&
     240 | +    // A peer on a privacy network cannot see our address, so its view of us is never useful.
    


    mzumsande commented at 12:27 PM on November 6, 2026:

    strictly speaking, the comment is not 100% correct, i2p peers can see our (i2p) address if -i2pacceptincoming=1 is set. I think the point is more that they cannot see our clearnet address, and our privacy-network address cannot be expressed in addrMe (addrv1) anyway.

  9. mzumsande commented at 12:31 PM on November 6, 2026: contributor

    Code Review ACK af633edefdc144d0f7b690782ba183ca6b5e68e9

  10. DrahtBot requested review from darosior on Nov 6, 2026
  11. DrahtBot requested review from jonatack on Nov 6, 2026
  12. danielabrozzoni approved
  13. danielabrozzoni commented at 11:00 PM on November 6, 2026: member

    tACK af633edefdc144d0f7b690782ba183ca6b5e68e9

    Happy to re-ACK if you address #36757 (review) :)

  14. net: ignore privacy-network peers' view of our address
    - if i make an outbound connection to a tor/i2p peer
    	me ---------> tor peer
      in the VERSION message the tor peer sends us back,
      there's a field which tells us about the address
      the peer thinks we are (addrMe) that can be used for
      self advertisement. Peers in privacy networks can't
      know this. So they send [::]:0.
    
      if a peer sends us a routable ipv4 address instead
      of [::]:0 - make sure to ignore it.
    
      if we don't ignore it, we can end up sending them
      as self advertisement the routable ipv4 address
      they sent us and our listening port. ignoring it
      will help prevent our custom clearnet port leaks
      to privacy networks.
    533fee6b9d
  15. test: check privacy-network peers' view of our address is not used 9cfd601400
  16. stratospher force-pushed on Nov 9, 2026
  17. mzumsande commented at 11:48 AM on November 10, 2026: contributor

    re-ACK 9cfd601

  18. DrahtBot requested review from danielabrozzoni on Nov 10, 2026
  19. fanquake added this to the milestone 33.0 on Nov 10, 2026
  20. danielabrozzoni approved
  21. danielabrozzoni commented at 1:45 PM on November 11, 2026: member

    ACK 9cfd6014005197d9d2d67dacb3c079980e3b284c

  22. sedited approved
  23. sedited commented at 1:18 PM on November 12, 2026: contributor

    ACK 9cfd6014005197d9d2d67dacb3c079980e3b284c

  24. sedited merged this on Nov 12, 2026
  25. sedited closed this on Nov 12, 2026


github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-11-18 16:51 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me