-
Notifications
You must be signed in to change notification settings - Fork 29

Description
Hi. Here is an example of what I mean:
# pgrep -a nftlb
13111 /usr/sbin/nftlb -c /var/lib/nftlb/config.json -l 7 -H 127.0.0.1 -P 5555 -k no
Note that there are exactly 22 spaces between -k
and the next argument. This reveals that my key contains exactly 20 characters to anyone with unfettered access to the process table. Knowing the key length would confer an advantage to any local attacker that might attempt to brute force the password.
In order to hide the key length, the only realistic option that I have is to take advantage of the hidepid
mount that the proc filesystem supports. For me, that is not a problem, but it is not a suitable arrangement for all users. Besides, the whitespace is aesthetically displeasing.
It would be preferable for the argument containing the key not to be padded out in this fashion, if it can be avoided. Moreover, it might be useful to have an option that allows for the key to be read from a file, or even a given file descriptor. To put this into perspective, here is how nftlb is launched by my current initscript:
start-stop-daemon -b -m -p "$pidfile" -2 "$errfile" -- "$command" \
-c "$NFTLB_CONFIG" \
-l "$NFTLB_LOGLEVEL" \
-H "$NFTLB_HOST" \
-P "$NFTLB_PORT" \
-k "$NFTLB_KEY" \
$NFTLB_IPV6
If there were a --keyfile
option, say, then I could potentially do this:
--keyfile <(printf %s "$NFTLB_KEY")
However, this would require bash, which is a problem for some environments - not least, Gentoo's OpenRC. For more flexibility, a --key-fd
option might be useful. Imagine being able to do the following …
# Read from a key file
nftlb --key-fd 3 ... 3</path/to/keyfile
# Read the key from STDIN
printf %s "$NFTLB_KEY" | nftlb --key-fd 0 ...
What do you think?