# 安全审计

<span style="color: rgb(224, 62, 45);">**<span style="font-family: 等线; mso-ascii-theme-font: minor-fareast; mso-fareast-theme-font: minor-fareast; mso-hansi-theme-font: minor-fareast;">测评项：<span lang="EN-US">a) </span>应启用安全审计功能，审计覆盖到每个用户，对重要的用户行为和重要安全事件进行审计。</span>**</span>

**<span style="font-family: 等线; mso-ascii-theme-font: minor-fareast; mso-fareast-theme-font: minor-fareast; mso-hansi-theme-font: minor-fareast;">核查点：日志要素</span>**

<p class="callout info"><span style="font-family: 等线; mso-ascii-theme-font: minor-fareast; mso-fareast-theme-font: minor-fareast; mso-hansi-theme-font: minor-fareast;">MySQL不对特定用户执行日志收集策略，默认覆盖所有用户。仅关注MySQL是否收集登录失败（**log\_error**）/ SQL语句执行（**log\_bin**）日志。</span></p>

<p class="callout warning"><span style="font-family: 等线; mso-ascii-theme-font: minor-fareast; mso-fareast-theme-font: minor-fareast; mso-hansi-theme-font: minor-fareast;">非必要**不推荐开启 general\_log** ，开启后MySQL会记录全量日志，极易影响系统的稳定运行。</span></p>

**<span style="font-family: 等线; mso-ascii-theme-font: minor-fareast; mso-fareast-theme-font: minor-fareast; mso-hansi-theme-font: minor-fareast;">核查命令</span>**

```mysql
show variables like 'log%';
```

<span style="font-family: 等线;">**核查效果**</span>

[![](https://cdn.sa.net/2025/08/28/o6aLwtv7GuBnlYe.png)](https://smms.app/image/o6aLwtv7GuBnlYe)

**<span style="font-family: 等线; mso-ascii-theme-font: minor-fareast; mso-fareast-theme-font: minor-fareast; mso-hansi-theme-font: minor-fareast;">测评项：<span lang="EN-US">b) </span>审计记录应包括事件的日期和时间、用户、事件类型、事件是否成功及其他与审计相关的信息。</span>**

**<span style="font-family: 等线; mso-ascii-theme-font: minor-fareast; mso-fareast-theme-font: minor-fareast; mso-hansi-theme-font: minor-fareast;">测评方法</span>**

<span style="font-family: 等线; mso-ascii-theme-font: minor-fareast; mso-fareast-theme-font: minor-fareast; mso-hansi-theme-font: minor-fareast;">（<span lang="EN-US">1</span>）执行“<span lang="EN-US">mysql&gt;show variables like ‘log\_%’</span>”命令，查看输出的日志内容是否覆盖所有用户，并核查审计记录覆盖的内容。</span>

<span style="font-family: 等线; mso-ascii-theme-font: minor-fareast; mso-fareast-theme-font: minor-fareast; mso-hansi-theme-font: minor-fareast;">（<span lang="EN-US">2</span>）核查是否已使用第三方审计工具增强<span lang="EN-US">MySQL</span>的日志审计功能。如果使用了第三方审计工具，则查看其审计内容是否包含事件的日期和事件、用户、事件类型、事件是否成功及其他与审计相关的信息。</span>

**<span style="font-family: 等线; mso-ascii-theme-font: minor-fareast; mso-fareast-theme-font: minor-fareast; mso-hansi-theme-font: minor-fareast;">操作步骤<span lang="EN-US">&amp;</span>预期结果</span>**

<span style="font-family: 等线; mso-ascii-theme-font: minor-fareast; mso-fareast-theme-font: minor-fareast; mso-hansi-theme-font: minor-fareast;">（<span lang="EN-US">1</span>）数据库本地启用了日志审计功能，审计内容覆盖每个用户，能够记录重要的用户行为和重要安全事件。</span>

<span lang="EN-US" style="font-family: 等线; mso-ascii-theme-font: minor-fareast; mso-fareast-theme-font: minor-fareast; mso-hansi-theme-font: minor-fareast;">①</span><span style="font-family: 等线; mso-ascii-theme-font: minor-fareast; mso-fareast-theme-font: minor-fareast; mso-hansi-theme-font: minor-fareast;"> <span lang="EN-US">show variables like 'log\_%';</span></span>

<span lang="EN-US" style="font-family: 等线; mso-ascii-theme-font: minor-fareast; mso-fareast-theme-font: minor-fareast; mso-hansi-theme-font: minor-fareast;"> </span><span lang="EN-US">[<span style="font-family: 等线; mso-ascii-theme-font: minor-fareast; mso-fareast-theme-font: minor-fareast; mso-hansi-theme-font: minor-fareast; color: windowtext; mso-no-proof: yes; text-decoration: none; text-underline: none;"><span style="mso-ignore: vglayout;">![](https://document.nat.ac.cn/uploads/images/gallery/2025-08/embedded-image-ogfndk3p.png)</span></span>](https://document.nat.ac.cn/uploads/images/gallery/2025-07/Youimage.png)</span>

<span lang="EN-US" style="font-family: 等线; mso-ascii-theme-font: minor-fareast; mso-fareast-theme-font: minor-fareast; mso-hansi-theme-font: minor-fareast;">②</span><span style="font-family: 等线; mso-ascii-theme-font: minor-fareast; mso-fareast-theme-font: minor-fareast; mso-hansi-theme-font: minor-fareast;"> <span lang="EN-US">show global variables like '%general%';</span></span>

<span lang="EN-US">[<span style="font-family: 等线; mso-ascii-theme-font: minor-fareast; mso-fareast-theme-font: minor-fareast; mso-hansi-theme-font: minor-fareast; color: windowtext; mso-no-proof: yes; text-decoration: none; text-underline: none;"><span style="mso-ignore: vglayout;">![表格

AI 生成的内容可能不正确。](https://document.nat.ac.cn/uploads/images/gallery/2025-08/embedded-image-nuntjbtk.png)</span></span>](https://document.nat.ac.cn/uploads/images/gallery/2025-07/Y0limage.png)</span>

<span style="font-family: 等线; mso-ascii-theme-font: minor-fareast; mso-fareast-theme-font: minor-fareast; mso-hansi-theme-font: minor-fareast;">（<span lang="EN-US">2</span>）使用了第三方数据库审计产品，审计内容覆盖每个用户，能够记录重要的用户行为和重要安全事件。</span>

**<span style="font-family: 等线; mso-ascii-theme-font: minor-fareast; mso-fareast-theme-font: minor-fareast; mso-hansi-theme-font: minor-fareast;">测评项：<span lang="EN-US">c) </span>应对审计记录进行保护，定期备份，避免受到未预期的删除、修改或覆盖等。</span>**

**<span style="font-family: 等线; mso-ascii-theme-font: minor-fareast; mso-fareast-theme-font: minor-fareast; mso-hansi-theme-font: minor-fareast;">测评方法</span>**

<span style="font-family: 等线; mso-ascii-theme-font: minor-fareast; mso-fareast-theme-font: minor-fareast; mso-hansi-theme-font: minor-fareast;">（<span lang="EN-US">1</span>）访谈管理员，了解审计记录的保护方式。核查审计记录是否定期备份，了解备份策略。</span>

<span style="font-family: 等线; mso-ascii-theme-font: minor-fareast; mso-fareast-theme-font: minor-fareast; mso-hansi-theme-font: minor-fareast;">（<span lang="EN-US">2</span>）核查是否已严格限制用户访问审计记录的权限。</span>

**<span style="font-family: 等线; mso-ascii-theme-font: minor-fareast; mso-fareast-theme-font: minor-fareast; mso-hansi-theme-font: minor-fareast;">操作步骤<span lang="EN-US">&amp;</span>预期结果</span>**

<span style="font-family: 等线; mso-ascii-theme-font: minor-fareast; mso-fareast-theme-font: minor-fareast; mso-hansi-theme-font: minor-fareast;">（<span lang="EN-US">1</span>）采用备份、转存等手段对审计记录进行保护，避免未预期的删除、修改或覆盖，数据库本地日志保存时间超过<span lang="EN-US">6</span>个月。</span>

<span lang="EN-US">[<span style="font-family: 等线; mso-ascii-theme-font: minor-fareast; mso-fareast-theme-font: minor-fareast; mso-hansi-theme-font: minor-fareast; color: windowtext; mso-no-proof: yes; text-decoration: none; text-underline: none;"><span style="mso-ignore: vglayout;">![图片包含 表格

AI 生成的内容可能不正确。](https://document.nat.ac.cn/uploads/images/gallery/2025-08/embedded-image-sukv3uft.png)</span></span>](https://document.nat.ac.cn/uploads/images/gallery/2025-07/knhimage.png)</span>

**<span lang="EN-US" style="font-family: 等线; mso-ascii-theme-font: minor-fareast; mso-fareast-theme-font: minor-fareast; mso-hansi-theme-font: minor-fareast;"> exprie\_logs\_days</span><span style="font-family: 等线; mso-ascii-theme-font: minor-fareast; mso-fareast-theme-font: minor-fareast; mso-hansi-theme-font: minor-fareast;">为日志存储时间（已经通过“<span lang="EN-US">set global expire\_logs\_days = 180;</span>”命令设置保存时间）</span>**

<span style="font-family: 等线; mso-ascii-theme-font: minor-fareast; mso-fareast-theme-font: minor-fareast; mso-hansi-theme-font: minor-fareast;">（<span lang="EN-US">2</span>）采用第三方数据库审计产品审计记录保存时间超过<span lang="EN-US">6</span>个月。</span>

**<span style="font-family: 等线; mso-ascii-theme-font: minor-fareast; mso-fareast-theme-font: minor-fareast; mso-hansi-theme-font: minor-fareast;">测评项：<span lang="EN-US">d) </span>应对审计进程进行保护，防止未经授权的中断。</span>**

**<span style="font-family: 等线; mso-ascii-theme-font: minor-fareast; mso-fareast-theme-font: minor-fareast; mso-hansi-theme-font: minor-fareast;">测评方法</span>**

<span style="font-family: 等线; mso-ascii-theme-font: minor-fareast; mso-fareast-theme-font: minor-fareast; mso-hansi-theme-font: minor-fareast;">（<span lang="EN-US">1</span>）核查是否已严格限制管理员、审计员的权限。</span>

<span style="font-family: 等线; mso-ascii-theme-font: minor-fareast; mso-fareast-theme-font: minor-fareast; mso-hansi-theme-font: minor-fareast;">（<span lang="EN-US">2</span>）尝试以用户身份重启实例、关闭审计功能，查看是否能成功（应为否）。</span>

**<span style="font-family: 等线; mso-ascii-theme-font: minor-fareast; mso-fareast-theme-font: minor-fareast; mso-hansi-theme-font: minor-fareast;">操作步骤<span lang="EN-US">&amp;</span>预期结果</span>**

<span style="font-family: 等线; mso-ascii-theme-font: minor-fareast; mso-fareast-theme-font: minor-fareast; mso-hansi-theme-font: minor-fareast;">（<span lang="EN-US">1</span>）非审计员账户无法中断审计进程，审计进程已受到保护。</span>

<span lang="EN-US">[<span style="font-family: 等线; mso-ascii-theme-font: minor-fareast; mso-fareast-theme-font: minor-fareast; mso-hansi-theme-font: minor-fareast; color: windowtext; mso-no-proof: yes; text-decoration: none; text-underline: none;"><span style="mso-ignore: vglayout;">![](https://document.nat.ac.cn/uploads/images/gallery/2025-08/embedded-image-7pmvf8pq.png)</span></span>](https://document.nat.ac.cn/uploads/images/gallery/2025-07/JSOimage.png)</span>

<span style="font-family: 等线; mso-ascii-theme-font: minor-fareast; mso-fareast-theme-font: minor-fareast; mso-hansi-theme-font: minor-fareast;">（<span lang="EN-US">2</span>）非审计员账户无法对审计进程纪念性开启、关闭操作。对这类操作有日志记录。</span>

<span lang="EN-US" style="font-family: 等线; mso-ascii-theme-font: minor-fareast; mso-fareast-theme-font: minor-fareast; mso-hansi-theme-font: minor-fareast;"></span>