TMAegis
More rules for postgres

TMA-POSTGRES-5.1

Do Not Specify Passwords in the Command Line

MediumLevel 1Manual reviewpostgres

Description

When a command is executed on the command line, for example ; psql postgresql://postgres:PASSWORD@host the password may be visible in the user's shell/command history or in the process list, thus exposing the password to other entities on the server.

How it is checked

Audit method: Manual review

This recommendation cannot be checked automatically. A scan lists it with these instructions when you pass --include-manual.

Check the process list (sudo ps -few) and shell histories (history, ~/.bash_history) for psql/pg_dump invocations that contain a password, e.g. in a connection string (password=...). Any visible password is a fail.

How it is fixed

Fix method: Guidance or infrastructure patch

Do not pass passwords on the command line; use ~/.pgpass (mode 0600), a service file without passwords, or certificate authentication, and clear exposed history entries.

Properties

Operating systems
Any
Tags
postgresdatabasecredentialsmanual
Reference
CIS PostgreSQL 18 Benchmark v1.0.0 - 5.1 Do Not Specify Passwords in the Command Line