Stop using environment variables for sending database passwords to MariaDB/MySQL #1009
Labels
No labels
blocked
breaking
bug
data loss
design finalized
good first issue
new feature area
question / support
security
waiting for response
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
borgmatic-collective/borgmatic#1009
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
What I'd like to do and why
Providing passwords to MariaDB/MySQL via environment variable (e.g.
MYSQL_PWD, which borgmatic uses today) is considered insecure. That's likely because the password can potentially be spied upon by child processes or, with root access, by looking at OS-level process metadata.So as part of this ticket, modify the borgmatic MariaDB and MySQL hooks to pass the configured password to the database client command via a more secure mechanism.
Other notes / implementation ideas
One idea is to use the
mariadb/mysql--defaults-extra-fileflag to pass in a temporary file path that contains something like:However, this would have to be done very carefully to avoid potentially leaking the password via that file, say if the permissions aren't sufficiently restrictive or an attacker puts something at the file path before borgmatic writes to it.
Ideally, we could instead give the password to
mariadb/mysqlvia an anonymous pipe like we do with the Borg encryption passphase, but that doesn't appear possible in this case.A related alternative might be to pass a named pipe containing the password to
--defaults-extra-file, but it's unclear that that's any more secure than a standard file for this use case.I actually managed to get a prototype working with an anonymous pipe!
This is implemented in main and will be part of the next release!
Released in borgmatic 1.9.13!