Files
kenaito-lab/System/VULNERABILITY_FIX.md
T
odboy 90da24086c refactor: 移除子镜像中无效的时区设置与 yum 换源命令
- ALinux3 官方源已使用 mirrors.aliyun.com,sed 换源为空操作
- 时区已由 ENV TimeZone 控制,/etc/localtime 运行时被宿主机覆盖
- 同步更新 VULNERABILITY_FIX.md 示例
2025-07-19 21:15:16 +08:00

148 lines
4.2 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# 基础镜像漏洞修复流程
## 镜像信息
| 项目 | 值 |
|-------|---------------------------------------------------------------------------------------|
| 镜像名称 | `registry.cn-shanghai.aliyuncs.com/odboy/kenaito:alinux3-update20261111` |
| 基础系统 | Alibaba Cloud Linux 3 (Soaring Falcon) |
| 基础镜像 | `alibaba-cloud-linux-3-registry.cn-hangzhou.cr.aliyuncs.com/alinux3/alinux3:220901.1` |
| 已安装包数 | 128 |
| 可更新包数 | 110 |
## 漏洞扫描结果
### trivy 扫描
trivy 无法识别 alinux3 的 OS 类型,系统包漏洞未被扫描,仅检测到 Python 包漏洞:
| 严重级别 | 数量 |
|----------|----|
| CRITICAL | 0 |
| HIGH | 3 |
| MEDIUM | 1 |
| LOW | 1 |
**Python 包漏洞 (setuptools 39.2.0)**:
- CVE-2022-40897 (HIGH) - ReDoS
- CVE-2024-6345 (HIGH) - 远程代码执行
- CVE-2025-47273 (HIGH) - 路径遍历
- CVE-2026-59890 (MEDIUM) - MANIFEST.in 绕过
- GHSA-xmj3-9gf7-h52w (LOW) - Windows 路径逃逸
### yum check-update 结果
110 个系统包可更新,包括关键组件:
- `bash`, `glibc`, `openssl-libs`, `curl`, `sudo`
- `coreutils`, `systemd-libs`, `krb5-libs`
- `gnutls`, `libarchive`, `pam` 等
---
## 修复步骤
### 方式一:容器内修复并 commit(推荐)
```bash
# 1. 启动容器
docker run -it --name fix-vuln \
registry.cn-shanghai.aliyuncs.com/odboy/kenaito:alinux3-update20261111 \
/bin/bash
# 2. 在容器内执行全量升级
yum update -y && yum clean all
# 3. 验证升级结果
yum check-update # 应返回空或仅显示刚更新的包
rpm -qa | wc -l # 确认包数量
# 4. 退出容器(Ctrl+D 或 exit)
# 5. 提交为新镜像
docker commit fix-vuln registry.cn-shanghai.aliyuncs.com/odboy/kenaito:alinux3-update$(date +%Y%m%d)
# 6. 推送新镜像
docker push registry.cn-shanghai.aliyuncs.com/odboy/kenaito:alinux3-update$(date +%Y%m%d)
# 7. 清理容器
docker rm fix-vuln
```
### 方式二:修改 Dockerfile 重建
修改 `System/Dockerfile`,在现有 RUN 指令后追加升级命令:
```dockerfile
FROM alibaba-cloud-linux-3-registry.cn-hangzhou.cr.aliyuncs.com/alinux3/alinux3:220901.1
LABEL MAINTAINER="tianjun@odboy.cn"
ENV TimeZone=Asia/Shanghai
WORKDIR /home/admin
RUN yum update -y && yum clean all; \
rm -rf /usr/lib/python3.6
```
> 说明:ALinux3 官方镜像的 repo 已使用 `mirrors.aliyun.com`,不需要再做 `mirrors.cloud.aliyuncs.com` 换源;
> 时区由 `ENV TimeZone` 控制,运行时通常会被容器引擎挂载的宿主机 `/etc/localtime` 覆盖,
> 因此子镜像也不再重复 `ln -snf ... /etc/localtime`。
然后执行构建:
```bash
cd System/
bash build.sh
```
### 方式三:仅修复特定 CVE
如果只想修复特定漏洞,可指定包名:
```bash
# 示例:仅升级 openssl 和 glibc
yum update -y openssl-libs glibc && yum clean all
```
---
## 修复后验证
```bash
# 重新扫描
trivy image registry.cn-shanghai.aliyuncs.com/odboy/kenaito:alinux3-fix<新日期>
# 检查可更新包
docker run --rm <新镜像> yum check-update
```
---
## 更新下游镜像
基础镜像更新后,需要更新所有下游镜像的 FROM 标签:
```bash
# 查找所有引用当前基础镜像的 Dockerfile
grep -r "alinux3-fix" --include="Dockerfile" .
```
涉及目录:
- `Base/Compile/` - 编译环境
- `Base/Runtime/` - 运行环境
- `Base/Composite/` - 编译与运行环境
- 其他所有基于 System 构建的镜像
---
## 注意事项
1. **trivy 限制**:trivy 不支持 alinux3 系统包扫描,系统级漏洞需通过 `yum check-update` 检查
2. **Python 包**:setuptools 是系统自带 Python 包,升级可能影响系统工具,建议保持现状或谨慎升级
3. **镜像标签**:建议使用日期标签(如 `alinux3-update20261111`)便于追溯
4. **构建缓存**:重建时可使用 `--no-cache` 确保使用最新包:
```bash
docker build --no-cache -t <镜像名> .
```