# cannot be used rpcpassword (or bitcoin.conf in general) #13143

issue knoxcard openend this issue on May 1, 2018
  1. knoxcard commented at 10:04 pm on May 1, 2018: contributor

    I spent hours trying to solve this bug and the solution was so simple. My rpcpassword in my bitcoin.conf file contained a ‘#’ character.

    Prevent this from happening, by outputting this an error or warning when users run bitcoind.

    Right now, you can have a # character as a password and it will work on the command line but will fail when you JSON-RPC.

  2. knoxcard renamed this:
    RPC Feature
    RPC Feature - rpcpassword
    on May 1, 2018
  3. fanquake added the label RPC/REST/ZMQ on May 1, 2018
  4. laanwj commented at 2:40 am on May 2, 2018: member

    I could reproduce this. The reason that this happens is that # starts a comment in .ini syntax, so the password gets truncated (ouch!). There seems to be no way to escape those characters, either:

    https://stackoverflow.com/questions/31921241/boostprogram-options-how-to-support-hash-character-in-a-value#31923154

    However - rpcpassword is the old way, there is now the rpcauth mechanism that stores passwords in hashed format. This is more in line with modern password storage security and could in principle be used to work around this.

    However, the script to hash the passwords, share/rpcauth/rpcauth.py currently has no way to specify a custom password, it will always generate a random password with 256 bit entropy. Which is more secure in any case… But doesn’t help with this specific issue :-)

  5. laanwj renamed this:
    RPC Feature - rpcpassword
    `#` cannot be used rpcpassword (or bitcoin.conf in general)
    on May 2, 2018
  6. fanquake commented at 2:59 am on May 2, 2018: member

    Have also recreated this. Using bitcoin-qt at https://github.com/bitcoin/bitcoin/commit/57c57df86f14874cfc4b280e04a7f44b19839c26. bitcoin.conf:

    0server=1
    1rpcuser=someuser
    2rpcpassword=some#pass
    

    This does not work:

    0curl -u someuser:some#pass -d '{"method": "getblockchaininfo" }' http://127.0.0.1:8332/
    

    However this does work:

    0curl -u someuser:some -d '{"method": "getblockchaininfo" }' http://127.0.0.1:8332/
    

    Expected output:

     0{"result":{"chain":"main",
     1"blocks":284781,
     2"headers":520824,
     3"bestblockhash":"000000000000000151b374e81b6f3956db0ab62502bd0fa90d461a31200244f2",
     4"difficulty":2621404453.064615,
     5"mediantime":1391850295,
     6"verificationprogress":0.1001564948409792,
     7"initialblockdownload":true,
     8"chainwork":"0000000000000000000000000000000000000000000015520d7cd30c40324dc2",
     9"size_on_disk":17344013534,
    10"pruned":false,
    11"softforks":[{"id":"bip34","version":2,"reject":{"status":true}},{"id":"bip66","version":3,"reject":{"status":false}},{"id":"bip65","version":4,"reject":{"status":false}}],"bip9_softforks":{"csv":{"status":"defined","startTime":1462060800,"timeout":1493596800,"since":0},"segwit":{"status":"defined","startTime":1479168000,"timeout":1510704000,"since":0}},
    12"warnings":"This is a pre-release test build - use at your own risk - do not use for mining or merchant applications"},
    13"error":null,
    14"id":null}
    
  7. laanwj commented at 3:16 am on May 2, 2018: member

    I’ve created #13146 to allow hashing a custom password in rpcauth.py, so that one can do:

    0$ ./rpcauth.py foo '###'
    1String to be appended to bitcoin.conf:
    2rpcauth=foo:31aa1353c61d96d89215887fd2d299$3cbfbe3059bd25361eded622079d7948277a42ff18fa8ff3e8b4816d343e2c7f
    3Your password:
    4###
    5$ echo "rpcauth=foo:31aa1353c61d96d89215887fd2d299$3cbfbe3059bd25361eded622079d7948277a42ff18fa8ff3e8b4816d343e2c7f" >> ~/.bitcoin/bitcoin.conf
    6$ bitcoind -regtest -daemon
    7$ bitcoin-cli -regtest -rpcuser="foo" -rpcpassword="###" -getinfo
    

    Though I think I’ve now lost track why I wanted a # in the password so badly in the first place.

  8. jonasschnelli commented at 6:51 am on May 2, 2018: contributor
    Thanks @laanwj for #13146. Though, I think silently dropping the post-#-part in non-hashed passphrase seems still something that should be fixed. Not sure how, … maybe by refusing to run with a such passphrase?
  9. laanwj commented at 10:12 am on May 2, 2018: member

    Though, I think silently dropping the post-#-part in non-hashed passphrase seems still something that should be fixed. Not sure how, … maybe by refusing to run with a such passphrase?

    The problem (see the stack overflow link) is that boost has no way to give you the part after #, so it’s undetectable whether the password (or any other option value) was chopped or not. The opportunity to fix this will be after boost::program_options is replaced with our own implementation (#12744).

  10. laanwj closed this on Nov 12, 2018

  11. laanwj referenced this in commit 90c0b6aca2 on Nov 12, 2018
  12. knst referenced this in commit e74373879b on Aug 10, 2021
  13. knst referenced this in commit a4062f57d9 on Aug 10, 2021
  14. knst referenced this in commit 705d36cd39 on Aug 16, 2021
  15. PastaPastaPasta referenced this in commit 42d1b0ba71 on Aug 23, 2021
  16. christiancfifi referenced this in commit b33ca8474a on Aug 27, 2021
  17. christiancfifi referenced this in commit 74858f06b4 on Aug 27, 2021
  18. christiancfifi referenced this in commit 33876d2450 on Aug 28, 2021
  19. christiancfifi referenced this in commit 1feb306462 on Aug 29, 2021
  20. christiancfifi referenced this in commit bfd9852f90 on Aug 29, 2021
  21. christiancfifi referenced this in commit b9d2e81286 on Aug 29, 2021
  22. DrahtBot locked this on Sep 8, 2021
  23. gades referenced this in commit c640400e04 on May 22, 2022

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-11-23 15:12 UTC

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