TMAegisBeta
更多 mysql 規則

MySQL

TMA-MYSQL-1.3

Disable MySQL Command History

低等級 2自動化mysql

說明

On Linux/UNIX, the MySQL client and MySQL Shell log statements executed interactively to a history file. The default MySQL Client file is named .mysql_history in the user's home directory. The files are split by language and named history.sql, history.js and history.py. Most interactive commands run in the MySQL client application are saved to a history file. Run as root; counts client history files under /home and /root that are not symlinks to /dev/null.

檢查方式

稽核方法: Shell 指令

shell
[ "$(id -u)" -eq 0 ] || exit 1; l=$(find /home /root -maxdepth 4 \( -name .mysql_history -o -path '*/.mysqlsh/history*' \) 2>/dev/null); n=0; for x in $l; do [ "$(readlink "$x")" = /dev/null ] || n=$((n+1)); done; echo "$n"
預期輸出
0

修補方式

修補方法: 操作指南或基礎設施修補檔

For each user remove the history file and prevent re-creation: rm -f ~<user>/.mysql_history && ln -s /dev/null ~<user>/.mysql_history, or export MYSQL_HISTFILE=/dev/null in the shell startup script; for MySQL Shell remove ~/.mysqlsh/history.* and run \option --persist history.autoSave=0.

屬性

作業系統
不限
標籤
mysqldatabasecredentialshistory
參考資料
CIS Oracle MySQL Community Server 8.4 Benchmark v1.1.0 - 1.3 Disable MySQL Command History

檢查此主機

請在您有權稽核的機器上執行此指令。掃描為唯讀操作。

shell
tmaegis scan --target mysql --level 2