TMAegis
postgres 관련 규칙 더 보기

TMA-POSTGRES-2.3

Disable PostgreSQL Command History

낮음레벨 1자동postgres

설명

On Linux/UNIX, the PostgreSQL client logs most interactive statements to a history file. The default PostgreSQL history file is named .psql_history in the user's home directory. The PostgreSQL command history should be disabled. Run as root; counts .psql_history files under /home, /root and the postgres home that are not symlinks to /dev/null.

점검 방법

감사 방식: 셸 명령

shell
[ "$(id -u)" -eq 0 ] || exit 1; h=$(getent passwd postgres | cut -d: -f6); l=$(find /home /root $h -maxdepth 3 -name .psql_history 2>/dev/null); n=0; for f in $l; do [ "$(readlink "$f")" = /dev/null ] || n=$((n+1)); done; echo "$n"
예상 출력
0

조치 방법

조치 방식: 가이드 또는 인프라 패치

For each user: rm -f ~<user>/.psql_history, then either add '\set HISTFILE /dev/null' to ~<user>/.psqlrc or ln -s /dev/null ~<user>/.psql_history; optionally set PSQL_HISTORY=/dev/null in /etc/environment.

속성

운영 체제
모두
태그
postgresdatabasecredentialshistory
참고 자료
CIS PostgreSQL 18 Benchmark v1.0.0 - 2.3 Disable PostgreSQL Command History

이 호스트 점검하기

감사 권한이 있는 시스템에서 실행하세요. 스캔은 읽기 전용입니다.

shell
tmaegis scan --target postgres