init: torcontrol argument should be validated #23589

issue laanwj openend this issue on November 25, 2021
  1. laanwj commented at 10:11 am on November 25, 2021: member

    I accidentally -torcontrol=1 today (instead of -listenonion=1) and was confused that it was accepted, as the argument needs to be host:port.

    Expected outcome would be an error message and exiting.

    Useful skills:

    • C++
    • Understanding of bitcoin core’s initialization sequence

    Want to work on this issue?

    For guidance on contributing, please read CONTRIBUTING.md before opening your pull request.

  2. laanwj added the label P2P on Nov 25, 2021
  3. laanwj added the label good first issue on Nov 25, 2021
  4. shaavan commented at 12:37 pm on November 25, 2021: contributor
    Let me try tackling this!
  5. shaavan commented at 1:21 pm on November 25, 2021: contributor

    Ok, so I was able to add a function successfully that can check if the given string is a valid <host>:<port> pair or not. The issue is that I cannot raise an error when the argument is wrongly passed when initializing bitcoind.

    In fact, bitcoind is not raising an error for any invalid argument passed at initialization.

    Screenshot from 2021-11-25 18-43-22

    Expected outcome would be an error message and exiting.

    Just a confirmation. When the ./src/bitcoind command is initially run with invalid parameters, do we expect an error message and exit? Or is it expected to occur later in the runtime of bitcoind?

  6. amovfx commented at 6:19 pm on November 25, 2021: none
    Is the Args Manager flags supposed to help with this?
  7. ityodadev commented at 5:18 am on November 26, 2021: none
    common sense would suggest there should be a message and some exit status, other than 0
  8. shaavan commented at 11:34 am on November 26, 2021: contributor
    A gentle ping, @laanwj. Would you please take a look at this comment?
  9. maflcko commented at 11:47 am on November 26, 2021: member
    git grep InitError might help you.
  10. bitcoin deleted a comment on Nov 27, 2021
  11. bitcoin deleted a comment on Nov 28, 2021
  12. bitcoin deleted a comment on Jan 5, 2022
  13. dakshp07 commented at 1:43 pm on March 4, 2022: none
    hey folks, I’m very new to the codebase and wanted to try my hands around this issue. Also, I saw a PR that is targeting this issue so what’s the update on that, is the issue still open?
  14. bitcoin deleted a comment on Mar 10, 2022
  15. amadeuszpawlik referenced this in commit b8cb03f143 on May 14, 2022
  16. amadeuszpawlik referenced this in commit 79befd6484 on May 14, 2022
  17. amadeuszpawlik referenced this in commit 69d4d7679d on May 14, 2022
  18. amadeuszpawlik referenced this in commit f48c207c99 on May 26, 2022
  19. bitcoin deleted a comment on May 31, 2022
  20. amadeuszpawlik referenced this in commit 8695e9ac03 on Oct 13, 2022
  21. amadeuszpawlik referenced this in commit e0a81da7ee on Oct 13, 2022
  22. amadeuszpawlik referenced this in commit 7ac9da5807 on Oct 13, 2022
  23. amadeuszpawlik referenced this in commit 5be4336fc5 on Oct 16, 2022
  24. vstoyanov referenced this in commit 88168de9db on Apr 11, 2023
  25. vstoyanov referenced this in commit 6fb9b723a1 on Apr 11, 2023
  26. kevkevinpal commented at 8:27 pm on June 30, 2023: contributor

    I see it not throwing the error because it is returning true here if it has no :

    https://github.com/bitcoin/bitcoin/blob/61d59fed74108f31eb4e9a2faa3f36422a37000e/src/util/strencodings.cpp#L117

    I can open a PR to change this to false but it would affect these files that use SplitHostPort in ./bitcoin/src

    0./src/test/fuzz/string.cpp:87
    1./src/test/netbase_tests.cpp:89
    2./src/util/strencodings.cpp:102
    3./src/util/strencodings.h:106
    4./src/bitcoin-cli.cpp:746
    5./src/net.cpp:547
    6./src/netbase.cpp:189
    7./src/init.cpp:1265
    8./src/init.cpp:1279
    

    We could also do a check just for -torcontrol to check if the : exists and if it doesn’t then throw an error @laanwj @MarcoFalke what do you think?

  27. kevkevinpal commented at 10:18 pm on September 20, 2023: contributor
    does this PR close this issue? https://github.com/bitcoin/bitcoin/pull/28101
  28. bufo24 referenced this in commit fd09b3ee65 on Oct 27, 2023
  29. bufo24 referenced this in commit 2d15e76df4 on Oct 27, 2023
  30. tdb3 commented at 9:12 pm on July 7, 2024: contributor

    Looks like we currently allow lookups for the -torcontrol host based on the state of -dns (default 1) (see below). If we don’t want to change that (e.g. to disallow allow hostnames, and allow only IP addresses), we’re somewhat limited in what would be considered invalid for -torcontrol. I’m thinking this gets clarified first.

    https://github.com/bitcoin/bitcoin/blob/bd5d1688b4311e21c0e0ff89a3ae02ef7d0543b8/src/torcontrol.cpp#L151


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-04 06:12 UTC

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