rabbitmq-server icon indicating copy to clipboard operation
rabbitmq-server copied to clipboard

rabbitmqctl encode command should support passing arguments via environment variables or interactive input

Open EricLin89 opened this issue 4 years ago • 4 comments

The current way of using "rabbitmqctl encode" is to pass the sensitive value and passphrase directly in the command line. The command will be captured by history or ps, which will cause possible information leak. Passing those arguments via environment variables or interactive input is a more secure way.

EricLin89 avatar Sep 25 '21 10:09 EricLin89

Environment variables are not much better unless if you disable /proc on Linux, for what it's worth. On Windows I am not sure much can be done with regard to environment protection since you can just read it from memory (assuming user is the same).

If we decide to do something here it should be to add interactive input only.

lhoguin avatar Sep 27 '21 09:09 lhoguin

read command can help you A1:~ # read -rs str_sensitive A1:~ # echo $str_sensitive test A1:~ # rabbitmqctl encode $str_sensitive $str_sensitive Encrypting value ... {encrypted,<<"eVq70yWpxxcX9uJtMbzoNJv9hwibQduf4VMNI5DhhCFC1G5dj794Uacx4NJZrz4xyfZM1cQ0dF7KhZ4r1KuMKg==">>} A1:~ #

zhgjun avatar Oct 08 '21 10:10 zhgjun

@zhgjun Thank you for your suggestion, but I'm afraid it won't solve the problem. Because in ps, $str_sensitive will be replaced by the actual value.

localhost:~ # var=100 localhost:~ # sleep $var & [1] 6521 localhost:~ # ps -ef|grep sleep|grep -v grep root 6521 252954 0 19:10 pts/0 00:00:00 sleep 100

EricLin89 avatar Oct 18 '21 11:10 EricLin89

@zhgjun Thank you for your suggestion, but I'm afraid it won't solve the problem. Because in ps, $str_sensitive will be replaced by the actual value.

localhost:~ # var=100 localhost:~ # sleep $var & [1] 6521 localhost:~ # ps -ef|grep sleep|grep -v grep root 6521 252954 0 19:10 pts/0 00:00:00 sleep 100

The process of 'rabbitmqctl encode xx‘ will end quickly unless you run the command all the time. or you have to use a script : test.sh with content like this rabbitmqctl encode $env1 $env2

and you run it after set the env1 and env2 value. export env1=test export env2=test sh test.sh

zhgjun avatar Oct 25 '21 11:10 zhgjun