Stop using environment variables for sending database passwords to PostgreSQL #1012
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#1012
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 PostgreSQL via environment variable (e.g.
PGPASSWORD, which borgmatic uses today) has security implications. That's 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 PostgreSQL hook to pass the configured password to the database client command via a more secure mechanism.
Other notes / implementation ideas
#1009 changed the MariaDB/MySQL hooks to use an anonymous pipe instead of an environment variable for transmitting the database password. A similar approach could work for PostgreSQL. It might go something like this:
PGPASSWORDand--username.PGPASSFILE. The value of the file should be something like/dev/fd/9where "9" is the file descriptor of an anonymous pipe created for this purpose.*:*:*:myuser:thepasswordEDIT: This approach won't work, at least not via anonymous pipe, because Postgres disallows non-plain files to serve as the password file:
A PostgreSQL mailing list discussion on the topic starts here: https://postgrespro.com/list/id/CABvH9hXLDEhy8eGxLyXzaXMdPuQYd5_=f-u4VUZ4SQs_VMSe2Q@mail.gmail.com
Closing this wontfix for now... The anonymous pipe approach is a non-starter (see above). And while using a named temporary password file would be possible, doing it in such a way that it'd actually get cleaned up / deleted at the proper time would be a pain.