TMAegisBeta
更多 tdsql 规则

TDSQL

TMA-TDSQL-1.5

Ensure Passwords Are Not Passed via the Command Line

高级别 1自动化tdsql

说明

When using the MySQL client or TDSQL tools, passwords should not be specified via the command-line arguments -p<password> or --password=. Counts running MySQL client processes and shell-history entries that pass a password inline (-p<password> or --password=). Restricted to MySQL client tools to avoid false matches such as mkdir -p.

检查方式

审计方法: Shell 命令

shell
out=$(ps -eo args= 2>/dev/null) || exit 1; p=$(printf '%s\n' "$out" | grep -v tdsql_cli_pw_audit | grep -cE '(mysql|mysqladmin|mysqldump|mysqlbinlog|mysqlsh)[^|;]*[[:space:]](-p[^[:space:]]|--password=)' || true); h=$(cat /root/.bash_history /home/*/.bash_history 2>/dev/null | grep -cE '(mysql|mysqladmin|mysqldump|mysqlbinlog|mysqlsh)[^|;]*[[:space:]](-p[^[:space:]]|--password=)' || true); echo $((p + h)) # tdsql_cli_pw_audit
预期输出
0

修复方式

修复方法: 操作指南或基础设施补丁

Use a MySQL option file (~/.my.cnf with [client] user/password, mode 600) or the TDSQL encrypted credential system instead of -p<password>; clear affected shell history entries and rotate any exposed passwords.

属性

操作系统
任意
标签
tdsqlcredentials
参考
CIS Tencent TDSQL 10.3.22 Benchmark v1.0.0 - 1.5 Ensure Passwords Are Not Passed via the Command Line

检查本机

请在您有权审计的机器上运行此命令。扫描为只读操作。

shell
tmaegis scan --target tdsql