Wrong listening port could be assumed resulting in bogus self-advertise #20184

issue vasild openend this issue on October 19, 2020
  1. vasild commented at 8:29 am on October 19, 2020: member

    If -bind= is provided with a :port part or if -whitebind= is provided (it is required to always have :port) and they contain non-standard port, then the wrong listening port will be assumed - the value of -port= or the default 8333 (if -port= is not provided). We would not be listening on that.


    1.

    Expected behavior

    If -bind=addr1:P -externalip=addr2 is provided then we would listen on port P and our site should be self-advertised as addr2:P.

    Actual behavior

    We would self-advertise as addr2:Q, whereas nobody is listening on port Q (the value of -port= or the default 8333).

    To reproduce

    Run bitcoind with -bind= providing a routable address (127.0.0.1 or 10.0.0.1 will not suffice) and port: bitcoind -bind=138.68.248.245:9000 -externalip=138.0.0.1, observe that 138.0.0.1:8333 is in localaddresses: bitcoin-cli getnetworkinfo |jq .localaddresses.


    During p2p handshake we receive a version message from the peer that contains our address:port [1] as perceived and claimed by the peer.


    2.

    Expected behavior

    During initial self-advertise we may relay [1] to the peer for outbound connections. In this case we should override the :port part with our actual listening port.

    Actual behavior

    The port gets overriden with the value of -port= or the default 8333.

    To reproduce

    Run in gdb.


    3.

    Expected behavior

    During periodic self-advertise we may relay [1] to the peer. We should use the address from the version message and for port:

    • for outbound connections: our actual listening port
    • for inbound connections: the port the peer told us in [1]

    Actual behavior

    The port gets overriden with the value of -port= or the default 8333, regardless of whether it is an outbound or inbound connection.

    To reproduce

    Run in gdb.


    4.

    Expected behavior

    If -discover is enabled and -bind=addr:port is used then during startup we should assume as local address just addr:port.

    Actual behavior

    During startup we assume the addresses from all interfaces of the machine with a bogus port (the value of -port= or the default 8333). For example if the machine has two interfaces with addresses 1.1.1.1 and 2.2.2.2 and -bind=1.1.1.1:9000 is used, then we would wrongly assume and self-advertise 1.1.1.1:8333 and 2.2.2.2:8333.

    To reproduce

    Similar to 1.: bitcoin-cli getnetworkinfo |jq .localaddresses


    5.

    Expected behavior

    If UPnP is enabled, we ask the router for its external IP address, assume that external address for self-advertise and set up a port mapping “external port on the router -> our internal address:port”. We should use a correct port that we actually listen to.

    Actual behavior

    Wrong port is used and mapping is redirected to a port on which nobody is listening.

    To reproduce

    Use -bind=10.0.0.1:9000 and check with the router that a mapping like “external_address_on_router:8333 -> 10.0.0.1:8333” is set.

  2. vasild added the label Bug on Oct 19, 2020
  3. fanquake added the label P2P on Oct 19, 2020
  4. vasild referenced this in commit edf748a330 on Oct 19, 2020
  5. vasild referenced this in commit 9334d2aed3 on Oct 19, 2020
  6. vasild referenced this in commit 5802e4d48a on Oct 19, 2020
  7. vasild referenced this in commit 1f88f9bb22 on Oct 19, 2020
  8. vasild referenced this in commit 7535c02d0b on Oct 19, 2020
  9. vasild referenced this in commit 73b7a3d6fe on Oct 19, 2020
  10. vasild referenced this in commit 9dd3f1d212 on Oct 20, 2020
  11. vasild referenced this in commit 202d8dfe8a on Oct 20, 2020
  12. vasild referenced this in commit b476f76f6a on Oct 20, 2020
  13. vasild referenced this in commit e6c3de7178 on Oct 20, 2020
  14. vasild referenced this in commit 3fe113e8ee on Oct 22, 2020
  15. vasild referenced this in commit 1ae0d404f8 on Oct 22, 2020
  16. vasild referenced this in commit 37f2dee18f on Oct 22, 2020
  17. vasild referenced this in commit 15a6a5948b on Oct 22, 2020
  18. vasild referenced this in commit 053ba089fc on Oct 22, 2020
  19. vasild referenced this in commit b69f98e317 on Dec 17, 2020
  20. vasild referenced this in commit 3e55fbfe31 on Dec 17, 2020
  21. vasild referenced this in commit 475be0e6ea on Jan 14, 2021
  22. vasild referenced this in commit 5647ca32e8 on Jan 14, 2021
  23. vasild referenced this in commit f1627ceac1 on Jan 17, 2021
  24. vasild referenced this in commit 58755690a7 on Jan 17, 2021
  25. vasild referenced this in commit 46691f6dea on Jan 18, 2021
  26. vasild referenced this in commit d8c6dc0b62 on Jan 18, 2021
  27. vasild referenced this in commit 7a07d2b552 on Jan 19, 2021
  28. vasild referenced this in commit 70cd1eaef9 on Jan 19, 2021
  29. vasild referenced this in commit 6be70211f3 on Feb 10, 2021
  30. vasild referenced this in commit 698590c571 on Feb 10, 2021
  31. vasild referenced this in commit 8ffcf8c114 on Feb 24, 2021
  32. vasild referenced this in commit 400cbd480a on Feb 24, 2021
  33. vasild referenced this in commit e0bd1e91a8 on Mar 15, 2021
  34. vasild referenced this in commit b6fb4b928d on Mar 15, 2021
  35. vasild referenced this in commit 39b4a0c309 on Mar 17, 2021
  36. vasild referenced this in commit 0c24971f97 on Mar 17, 2021
  37. vasild referenced this in commit e9ec177a2f on Mar 26, 2021
  38. vasild referenced this in commit 4977c0fdb5 on Mar 26, 2021
  39. vasild referenced this in commit 55454afd8b on Mar 26, 2021
  40. vasild referenced this in commit 7d5d2416e7 on Mar 26, 2021
  41. vasild referenced this in commit 77a8324cf0 on Apr 9, 2021
  42. vasild referenced this in commit 3501180d33 on Apr 9, 2021
  43. vasild referenced this in commit 7d06e0b4c0 on Apr 9, 2021
  44. vasild referenced this in commit 33b0a79df6 on Apr 9, 2021
  45. vasild referenced this in commit 847af77d6b on Apr 13, 2021
  46. vasild referenced this in commit a5590dcf9d on Apr 13, 2021
  47. vasild referenced this in commit 1092c00bb8 on Apr 14, 2021
  48. vasild referenced this in commit 7126e12fab on Apr 14, 2021
  49. vasild referenced this in commit 1e79b64055 on May 19, 2021
  50. vasild referenced this in commit 9c15f204e5 on May 19, 2021
  51. vasild referenced this in commit dec4da1a50 on May 19, 2021
  52. vasild referenced this in commit 2519696300 on May 19, 2021
  53. vasild referenced this in commit eedb2b32e4 on May 19, 2021
  54. vasild referenced this in commit b962cbc22c on May 19, 2021
  55. vasild referenced this in commit 3ef355b95d on Jul 20, 2021
  56. vasild referenced this in commit 4ea0a60f75 on Jul 20, 2021
  57. vasild referenced this in commit 40ca502467 on Jul 22, 2021
  58. vasild referenced this in commit 6813052724 on Jul 22, 2021
  59. vasild referenced this in commit 47606db1d7 on Jul 23, 2021
  60. vasild referenced this in commit 2aee1b92c5 on Jul 23, 2021
  61. vasild referenced this in commit 9528212c49 on Jul 29, 2021
  62. vasild referenced this in commit ad6c1fbe8f on Jul 29, 2021
  63. vasild referenced this in commit d91cb8af48 on Jul 29, 2021
  64. vasild referenced this in commit e4474f66d9 on Jul 29, 2021
  65. vasild referenced this in commit 20be6657e3 on Aug 20, 2021
  66. vasild referenced this in commit 812deb7470 on Aug 20, 2021
  67. vasild referenced this in commit a380a68e2d on Sep 29, 2021
  68. vasild referenced this in commit cb86c1fd20 on Sep 29, 2021
  69. vasild referenced this in commit a6d15f47c0 on Feb 11, 2022
  70. vasild referenced this in commit 38f49fc11d on Feb 11, 2022
  71. vasild referenced this in commit 7f8d5c46ac on Feb 14, 2022
  72. vasild referenced this in commit 35ec977b06 on Feb 14, 2022
  73. vasild referenced this in commit 0cfc0cd322 on Mar 2, 2022
  74. vasild referenced this in commit 7d64ea4a01 on Mar 2, 2022
  75. laanwj closed this on Mar 3, 2022

  76. laanwj referenced this in commit 30308cc380 on Mar 3, 2022
  77. janus referenced this in commit 6f29ae6d98 on Jul 24, 2022
  78. janus referenced this in commit d1bc862466 on Jul 24, 2022
  79. backpacker69 referenced this in commit 5b4cfb328d on Jan 18, 2023
  80. backpacker69 referenced this in commit a42b3fd4e9 on Jan 18, 2023
  81. DrahtBot locked this on Mar 3, 2023


vasild

Labels
Bug P2P


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: 2024-12-18 21:12 UTC

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