我的 Dockerfile 非常简单,代码如下。这是一个 Angular 应用程序。一旦我将代码合并到我的主分支 CodePipeline 接管,CodeBuild 将构建图像并推送到 ECR,而 CodeDeploy 将使用该图像部署 ECS Fargate 任务。一切正常。但是这张图片有 1 个严重漏洞。 CVE-2021-22945 - curl
node14:14182alpine312 基本上构建自:FROM node:14.18.2-alpine3.12 nginx:latest 是从 nginx:latest 构建的
FROM <awsaccountid>.dkr.ecr.<region>.amazonaws.com/node14:14182alpine312 as builder
WORKDIR /app
COPY ./hello-world-web/ /app/
RUN apk add --no-cache git
RUN npm install
RUN npm run build
FROM <awsaccountid>.dkr.ecr.<region>.amazonaws.com/nginx:latest
COPY --from=builder /app/dist/hello-world-web /usr/share/nginx/html
COPY --from=builder /app/nginx.conf /etc/nginx/conf.d/default.conf
EXPOSE 80
扫描 ECR Repo 的工具提到漏洞位于第 0 层。我可以在构建可修复此问题的图像时运行任何脚本吗?单独的节点和 nginx 图像没有这个严重的漏洞。似乎可以在运行 npm install 时引入它。非常感谢任何解决此问题的帮助。
最佳答案
我看到 libcurl 被 apk add git
引入(点击“depends”):https://pkgs.alpinelinux.org/package/edge/main/x86/git
但在 alpine 3.12 上,libcurl 版本为 7.79.1,不受 CVE 影响:https://nvd.nist.gov/vuln/detail/CVE-2021-22945
也许在 apk add
之前运行 apk update
并查看它是否引入了正确的版本?
关于docker - 如何修复 Docker 镜像中的严重漏洞?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/70398409/