docker scan 本地扫描镜像漏洞
Docker scan[1]本地扫描镜像漏洞
2020年年底,Docker hub推出镜像自动扫描的功能,同时Docker也支持了在本地通过Docker命令选项的方式支持镜像漏洞扫描,目前Docker Desktop for Mac以及window上的Docker都可以通过Docker scan子命令扫描本地镜像是否存在漏洞软件。
Docker Desktop For Mac
使用docker scan的时候需要登录Docker Hub的账号,同时docker scan支持一些不同的选项
Options: --accept-license 接受使用第三方扫描提供商 --dependency-tree 显示带有扫描结果的依赖树 --exclude-base 从漏洞扫描中排除基础镜像 (requires --file) -f, --file string 与image关联的Dockerfile,提供更详细的结果 --group-issues 聚合重复的漏洞并将其分组为1个漏洞 (requires --json) --json do 以json格式输出结果 --login 使用可选令牌(带有--token)向扫描提供程序进行身份验证,如果为空则使用web base令牌 --reject-license 拒绝使用第三方扫描提供商 --severity string 只报告提供级别或更高的漏洞(low|medium|high) --token string 登录到第三方扫描提供程序的认证令牌 --version 显示扫描插件版本
指定Dockerfile
$ docker scan -f Dockerfile docker-scan:e2e Testing docker-scan:e2e ... High severity vulnerability found ckin perl Description: Integer Overflow or Wraparound Info: https://snyk.io/vuln/SNYK-DEBIAN10-PERL-570802 Introduced through: git@1:2.20.1-2+deb10u3, meta-common-packages@meta From: git@1:2.20.1-2+deb10u3 > [email protected] From: git@1:2.20.1-2+deb10u3 > [email protected] > [email protected] From: git@1:2.20.1-2+deb10u3 > [email protected] > perl/[email protected] and 3 more... Introduced by your base image (golang:1.14.6) Organization: docker-desktop-test Package manager: deb Target file:&ernbsp; Dockerfile Project name: docker-image|99138c65ebc7 Docker image: 99138c65ebc7 Base image: golang:1.14.6 Licenses: enabled Tested 200 dependencies for known issues, found 157 issues. According to our scan, you are currently using the most secure version of the selected base image
不扫描该镜像的基础镜像
$ docker scan -f Dockerfile --exclude-base docker-scan:e2e Testing docker-scan:e2e ... Medium severity vulnerability found  s;in libidn2/libidn2-0 Description: Improper Input Validation Info: https://snyk.io/vuln/SNYK-DEBIAN10-LIBIDN2-474100 Introduced through: iputils/iputils-ping@3:20180629-2+deb10u1, [email protected], [email protected]+deb10u1, git@1:2.20.1-2+deb10u3 From: iputils/iputils-ping@3:20180629-2+deb10u1 > libidn2/[email protected]+deb10u1 From: [email protected] > libidn2/[email protected]+deb10u1 From: [email protected]+deb10u1 > curl/[email protected]+deb10u1 > libidn2/[email protected]+deb10u1 and 3 more... Introduced in your Dockerfile by 'RUN apk add -U --no-cache wget tar'&nbcasp; Organization: docker-desktop-test Package manager: deb Target file: Dockerfile Project name: docker-image|99138c65ebc7 Docker image: 99138c65ebc7 Base image: golang:1.14.6 Licenses: enabled Tested 200 dependencies for known issues, found 16 issues.
以json格式输出扫描结果
JSON格式显示镜像扫描结果
聚合分组显示扫描信息
$ docker scan --json --group-issues docker-scan:e2e { { "title": "Improper Chen ck for Dropped Privileges", ... "packageName": "bash", "language": "linux", "packageManager": "debian:10", "description": "## Overview An issue was discovered in disable_priv_mode in shell.c in GNU Bash through 5.0 patch 11. By default, if Bash is run with its effective UID not equal to its real UID, it will drop privileges by setting its effective UID to its real UID. However, it does so incorrectly.本地 On Linux and other systems that support "saved UID" functionality, the saved UID is not dropped. An attacker with command execution in the shell can use "enable -f" for runtime loading of a new builtin, which can be a shared object that calls setuid() and therefore regains privileges. However, binaries running with an effective UID of 0 are unaffected. ## References - [CONFIRM](https://security.netapp.com/advisory/ntap-20200430-0003/) - [Debian Security Tracker](https://security-tracker.debian.org/tracker/CVE-2019-18276) - [GitHub Commit](https://github.co扫描m/bminor/bash/commit/951bdaad7a18cc0dc1036bba86b18b90874d39ff) - [MISC](http://packetstormsecurity.com/files/155498/Bash-5.0-Patch-11-Privilege-Escalation.html) - [MISC](https://www.youtube.com/watch?v=-wGtxJ8opa8) - [Ubuntu CVE Tracker](http://people.ubuntu.com/~ubuntu-security/cve/CVE-2019-18276) ", "identifiers": { "ALTERNATIVE": [], "CVE": [ "CVE-2019-18276" ], "CWE": [ "CWE-273" ] 镜像 }, "severity": "low", "severityWithCritical": "low", "cvssScore": 7.8, "CVSSv3": "CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H/E:F", ... "from": [ "docker-image|docker-scan@e2e", "[email protected]" ], "upgradePath": [], "isUpgradable": false, "isPatchable": false, "name":漏洞 "bash", "version": "5.0-4" }, ... "summary": "880 vulnerable dependency paths", "filesystemPolicy": false, "filtered": { "ignore": [], "patch": [] }, "uniqueCount": 158, "projectName": "docker-image|docker-scan", "platform": "linux/amd64", "path": "docker-scan:e2e" }
显示指定级别的漏洞,只有do高于此级别的漏洞才会显示出来
$ docker scan --severity=medium docker-scan:e2e ./bin/docker-scan_darwin_amd64 scan --severity=medium docker-scan:e2e Testing docker-scan:e2e... Medium severity vulnerability found in sqlite3/libsqlite3-0 Description: Divide By Zero Info: https://snyk.io/vuln/SNYK-DEBIAN10-SQLITE3-466337 Introduced through: gnupg2/[email protected]+deb10u1, [email protected]+deb10u1, [email protected]+deb10u1 From: gnupg2/[email protected]+deb10u1 > gnupg2/[email protected]+deb10u1 > sqlite3/[email protected] From: [email protected]+deb10u1 > subversion/[email protected]+deb10u1 > sqlite3/[email protected] From:&nbcksp;[email protected]+deb10u1 > python-defaults/[email protected] > [email protected]+deb10u1 > python2.7/[email protected]+deb10u1 > sqlite3/[email protected] Medium severity vulnerability found in sqlite3/libsqlite3-0 Description: Uncontrolled Recursion ... High severity vulnerability found in binutils/binutils-common Description: Missing Release of Resource after Effective Lifetime Info: https://snyk.io/vuln/SNYK-DEBIAN10-BINUTILS-403318 Introduced through: gcc-defaults/g++@4:8.3.0-1 From: gcc-defaults/g++@4:8.3.0-1 > gcc-defaults/gcc@4:8.3.0-1 > [email protected] > [email protected] > binutils/[email protected] From: gcc-defaults/g++@4:8.3.0-1 > gcc-defaults/gcc@4:8.3.0-1 > [email protected] > [email protected] > binutils/[email protected] > binutils/[email protected] From: gcc-defaults/g++@4:8.3.0-1 > gcc-defaults/gcc@4:8.3.0-1 > [email protected] > [email protected] > binutils/[email protected] > binutils/[email protected] and 4 more... Organization: docker-desktop-test Package manager: deb Project name: docker-image|docker-scan Docker image: doc sker-scan:e2e Platform: linux/amd64 Licenses: enabled Tested 200 dependencies for known issues, found 37 issues. Linux上安装scan-cli插件
目前Linux系统上的Docker Engine尚未支持scan命令,因此可以通过插件形式使用,可以参考scan-cli-plugin[2]的文档,此处我在Ubuntu上通过apt安装一下
> cat /etc/apt/sources.list.d/docker.list deb [arch=amd64] https://mirrors.aliyun.com/docker-ce/linux/ubuntu xenial stable > apt-get update && apt-get install docker-scan-plugin
安装完成之后,登录Docker hub,然后同意访问Snyk即可。
参考资料
[1]docker scan:
https://docs.docker.com/engine/scan/
[2]scan-cli-plugin:
https://github.com/docker/scan-cli-plugin
- ·云计算开发:Python3-rindex()方法详解
- ·未来十年值得关注的十大云计算趋势
- ·云计算和大数据成为了一个行业的标配
- ·云计算开发:Python练习实例-输出所有素数
- ·处理人工智能任务必须知道的11个Python库
- ·2020下半年,中国整体云专业服务市场规模达91.2亿元人民币
- ·标签: 腾讯 喜马拉雅 宇树 GD01
- ·标签: Cloudflare 机器人防护 宕机事故 全球故障
- ·2021年成为数据科学专家的5个步骤
- ·边缘计算将在企业中扮演越来越重要的角色
- ·谷歌更新Gemini 2.5 Flash Lite,成为最快的专有模型
- ·标签: 零跑汽车 朱江明 廉洁合规 反腐举报
- ·Twitter移动应用新版内测 音频聊天室成中心
- ·标签: 李宁 2025年报 运动品牌 电商渠道
- ·标签: xAI Grok 4.1 LMArena
- ·瑞士三强联合发布开源大模型Apertus 挑战美国科技巨头
- ·比尔·盖茨小女儿创业杀入AI电商!Phia获800万美元融资,海莉·比伯、卡戴珊家族抢投,60万用户已用它“聪明购物”
- ·标签: 美团 2025年财报 即时零售 外卖
- ·谷歌员工组建全球工会联盟
- ·魔改GPT自动写网文,速度一秒十字,还能给太监作品无限续更 | 开源
- ·MiniMax推M2推理大模型:2300亿参数、100 token/s,专为智能Agent而生
- ·Salesforce宣布将裁员约10% 并关闭部分办公室
- ·中国红十字基金会联合阿里云发布数字救援平台,面向全社会救援力量开放注册
- ·标签: 中远海能 LNG船舶 油轮运力 LPG运输船
- ·Akamai在亚洲、欧洲、北美和拉丁美洲新增七个核心计算区域,扩展云网络
- ·IBM收购云解决方案供应商Expertus 扩展混合云数字支付解决方案
- ·标签: 香港航空 西捷航空 代码共享 国际航线
- ·特斯拉回应“机场禁止入内”:哨兵模式数据仅存储在车辆本地 另外特斯拉已在中国建立数据中心
- ·标签: 托伦斯 北方华创 中微公司 Lumentum
- ·腾讯全新AI绘画升级!微调技术让生成图像美感提升300%
- ·标签: 和铂医药 诺纳生物 免疫性疾病 肿瘤
- ·微软正式发布 GPT-realtime 模型,主打更逼真语音与多模态输入
- ·标签: 张雪峰 峰学蔚来 心源性猝死 教育科技
- ·每个用户10美元:Facebook财报不怕反垄断 怕的是苹果
- ·云安全日报210303:Debian无线配置管理软件发现执行任意代码漏洞,需要尽快升级
- ·免费、降价!阿里云可不是要打价格战
