Skip to content

Hide the bgp password from logs - #1721

Merged
fedepaol merged 4 commits into
metallb:mainfrom
fedepaol:hidepassword
Nov 29, 2022
Merged

Hide the bgp password from logs#1721
fedepaol merged 4 commits into
metallb:mainfrom
fedepaol:hidepassword

Conversation

@fedepaol

Copy link
Copy Markdown
Member

We expose the password in the logs in two places:

  • when the speaker container dumps the configuration, because an error happened or because the log level is raised to debug
  • in the reloader container, every time an frr configuration gets generated

Here, in both places we replace the password before logging.

@cgoncalves

Copy link
Copy Markdown
Contributor

I'm of the opinion that logging the password when debug is on is useful when troubleshooting (only reason why one would enable debug)

Comment thread frr-reloader/frr-reloader.sh Outdated

echo "Checking the configuration file syntax"
if ! python3 /usr/lib/frr/frr-reload.py --test --stdout "$FILE_TO_RELOAD" ; then
if ! python3 /usr/lib/frr/frr-reload.py --test --stdout "$FILE_TO_RELOAD" 2>&1 | sed 's/password.*/password xxxxx/g'; then

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

password <retracted>
is more descriptive of what happend here IMHO

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done, thanks!

@yuvalk

yuvalk commented Nov 25, 2022

Copy link
Copy Markdown
Contributor

I'm of the opinion that logging the password when debug is on is useful when troubleshooting (only reason why one would enable debug)

you can read the secret if what you need is (only) the password.
if you need the configuration, u can read it from debug log, and if you want to try it, you need to add the password in.

but getting the password from debug log is wrong.

consider the fact that logs can be stored on unencrypted disks and even in backups as well as (most common!) shipped to aggregator tools such as logstash/ splunk/ etc. so the opportunities of unauthorized access and data leak are growing.
best practices for secure coding is to treat passwords as secrets and as such mask them in logs. (or more generally - touch them as less as possible, dont carry them around, dont store them, etc.)

@fedepaol

Copy link
Copy Markdown
Member Author

I'm of the opinion that logging the password when debug is on is useful when troubleshooting (only reason why one would enable debug)

you can read the secret if what you need is (only) the password. if you need the configuration, u can read it from debug log, and if you want to try it, you need to add the password in.

but getting the password from debug log is wrong.

consider the fact that logs can be stored on unencrypted disks and even in backups as well as (most common!) shipped to aggregator tools such as logstash/ splunk/ etc. so the opportunities of unauthorized access and data leak are growing. best practices for secure coding is to treat passwords as secrets and as such mask them in logs. (or more generally - touch them as less as possible, dont carry them around, dont store them, etc.)

This, plus the fact that we can still rely on vtysh show running-config if we suspect the passwords are wrong / there's a drift between the configured password and the expected one make me tend to keep the current version

@fedepaol
fedepaol force-pushed the hidepassword branch 2 times, most recently from 2cc0115 to 3588546 Compare November 28, 2022 08:50

@oribon oribon left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

Comment thread frr-reloader/frr-reloader.sh
We obfuscate the password to avoid having it in clear in logs.

Signed-off-by: Federico Paolinelli <fpaoline@redhat.com>
When we have some errors or we have debug verb level enabled we dump the
full resources and the related configuration, including the bgp peer
password set by the user. Here we obfuscate it so it won't be visible in
logs.

Signed-off-by: Federico Paolinelli <fpaoline@redhat.com>
@fedepaol
fedepaol merged commit cd7c88d into metallb:main Nov 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants