“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支持一些不同的选项

  1. Options: 
  2.       --accept-license    接受使用第三方扫描提供商 
  3.       --dependency-tree   显示带有扫描结果的依赖树 
  4.       --exclude-base      从漏洞扫描中排除基础镜像 (requires --file) 
  5.   -f, --file string       与image关联的Dockerfile,提供更详细的结果 
  6.       --group-issues      聚合重复的漏洞并将其分组为1个漏洞 (requires --json) 
  7.       --json              以json格式输出结果 
  8.       --login             使用可选令牌(带有--token)向扫描提供程序进行身份验证,如果为空则使用web base令牌 
  9.       --reject-license    拒绝使用第三方扫描提供商 
  10.       --severity string   只报告提供级别或更高的漏洞(low|medium|high) 
  11.       --token string      登录到第三方扫描提供程序的认证令牌 
  12.       --version           显示扫描插件版本 

指定Dockerfile

  1. $ docker scan -f Dockerfile docker-scan:e2e 
  2. Testing docker-scan:e2e 
  3. ... 
  4.  High severity vulnerability found in perl 
  5.   Description: Integer Overflow or Wraparound 
  6.   Info: https://snyk.io/vuln/SNYK-DEBIAN10-PERL-570802 
  7.   Introduced through: git@1:2.20.1-2+deb10u3, meta-common-packages@meta 
  8.   From: git@1:2.20.1-2+deb10u3 > [email protected] 
  9.   From: git@1:2.20.1-2+deb10u3 > [email protected] > [email protected] 
  10.   From: git@1:2.20.1-2+deb10u3 > [email protected] > perl/[email protected] 
  11.   and 3 more... 
  12.   Introduced by your base image (golang:1.14.6) 
  13.  
  14.  
  15.  
  16. Organization:      docker-desktop-test 
  17. Package manager:   deb 
  18. Target file:       Dockerfile 
  19. Project name:      docker-image|99138c65ebc7 
  20. Docker image:      99138c65ebc7 
  21. Base image:        golang:1.14.6 
  22. Licenses:          enabled 
  23.  
  24. Tested 200 dependencies for known issues, found 157 issues. 
  25.  
  26. According to our scan, you are currently using the most secure version of the selected base image 

不扫描该镜像的基础镜像

  1. $ docker scan -f Dockerfile --exclude-base docker-scan:e2e 
  2. Testing docker-scan:e2e 
  3. ... 
  4.  Medium severity vulnerability found in libidn2/libidn2-0 
  5.   Description: Improper Input Validation 
  6.   Info: https://snyk.io/vuln/SNYK-DEBIAN10-LIBIDN2-474100 
  7.   Introduced through: iputils/iputils-ping@3:20180629-2+deb10u1, [email protected][email protected]+deb10u1, git@1:2.20.1-2+deb10u3 
  8.   From: iputils/iputils-ping@3:20180629-2+deb10u1 > libidn2/[email protected]+deb10u1 
  9.   From[email protected] > libidn2/[email protected]+deb10u1 
  10.   From[email protected]+deb10u1 > curl/[email protected]+deb10u1 > libidn2/[email protected]+deb10u1 
  11.   and 3 more... 
  12.   Introduced in your Dockerfile by 'RUN apk add -U --no-cache wget tar' 
  13.  
  14.  
  15.  
  16. Organization:      docker-desktop-test 
  17. Package manager:   deb 
  18. Target file:       Dockerfile 
  19. Project name:      docker-image|99138c65ebc7 
  20. Docker image:      99138c65ebc7 
  21. Base image:        golang:1.14.6 
  22. Licenses:          enabled 
  23.  
  24. Tested 200 dependencies for known issues, found 16 issues. 

以json格式输出扫描结果

 

JSON格式显示镜像扫描结果

聚合分组显示扫描信息

  1. $ docker scan --json --group-issues docker-scan:e2e 
  2.     { 
  3.       "title""Improper Check for Dropped Privileges"
  4.       ... 
  5.       "packageName""bash"
  6.       "language""linux"
  7.       "packageManager""debian:10"
  8.       "description""## Overview\nAn 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.\n\n## References\n- [CONFIRM](https://security.netapp.com/advisory/ntap-20200430-0003/)\n- [Debian Security Tracker](https://security-tracker.debian.org/tracker/CVE-2019-18276)\n- [GitHub Commit](https://github.com/bminor/bash/commit/951bdaad7a18cc0dc1036bba86b18b90874d39ff)\n- [MISC](http://packetstormsecurity.com/files/155498/Bash-5.0-Patch-11-Privilege-Escalation.html)\n- [MISC](https://www.youtube.com/watch?v=-wGtxJ8opa8)\n- [Ubuntu CVE Tracker](http://people.ubuntu.com/~ubuntu-security/cve/CVE-2019-18276)\n"
  9.       "identifiers": { 
  10.         "ALTERNATIVE": [], 
  11.         "CVE": [ 
  12.           "CVE-2019-18276" 
  13.         ], 
  14.         "CWE": [ 
  15.           "CWE-273" 
  16.         ] 
  17.       }, 
  18.       "severity""low"
  19.       "severityWithCritical""low"
  20.       "cvssScore": 7.8, 
  21.       "CVSSv3""CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H/E:F"
  22.       ... 
  23.       "from": [ 
  24.         "docker-image|docker-scan@e2e"
  25.         "[email protected]" 
  26.       ], 
  27.       "upgradePath": [], 
  28.       "isUpgradable"false
  29.       "isPatchable"false
  30.       "name""bash"
  31.       "version""5.0-4" 
  32.     }, 
  33.     ... 
  34.     "summary""880 vulnerable dependency paths"
  35.       "filesystemPolicy"false
  36.       "filtered": { 
  37.         "ignore": [], 
  38.         "patch": [] 
  39.       }, 
  40.       "uniqueCount": 158, 
  41.       "projectName""docker-image|docker-scan"
  42.       "platform""linux/amd64"
  43.       "path""docker-scan:e2e" 

显示指定级别的漏洞,只有高于此级别的漏洞才会显示出来

  1. $ docker scan --severity=medium docker-scan:e2e 
  2. ./bin/docker-scan_darwin_amd64 scan --severity=medium docker-scan:e2e 
  3.  
  4. Testing docker-scan:e2e... 
  5.  
  6.  Medium severity vulnerability found in sqlite3/libsqlite3-0 
  7.  Description: Divide By Zero 
  8.  Info: https://snyk.io/vuln/SNYK-DEBIAN10-SQLITE3-466337 
  9.  Introduced through: gnupg2/[email protected]+deb10u1, [email protected]+deb10u1, [email protected]+deb10u1 
  10.  From: gnupg2/[email protected]+deb10u1 > gnupg2/[email protected]+deb10u1 > sqlite3/[email protected] 
  11.  From[email protected]+deb10u1 > subversion/[email protected]+deb10u1 > sqlite3/[email protected] 
  12.  From[email protected]+deb10u1 > python-defaults/[email protected] > [email protected]+deb10u1 > python2.7/[email protected]+deb10u1 > sqlite3/[email protected] 
  13.  
  14.  Medium severity vulnerability found in sqlite3/libsqlite3-0 
  15.  Description: Uncontrolled Recursion 
  16. ... 
  17.  High severity vulnerability found in binutils/binutils-common 
  18.  Description: Missing Release of Resource after Effective Lifetime 
  19.  Info: https://snyk.io/vuln/SNYK-DEBIAN10-BINUTILS-403318 
  20.  Introduced through: gcc-defaults/g++@4:8.3.0-1 
  21.  From: gcc-defaults/g++@4:8.3.0-1 > gcc-defaults/gcc@4:8.3.0-1 > [email protected] > [email protected] > binutils/[email protected] 
  22.  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] 
  23.  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] 
  24.  and 4 more... 
  25.  
  26. Organization:      docker-desktop-test 
  27. Package manager:   deb 
  28. Project name:      docker-image|docker-scan 
  29. Docker image:      docker-scan:e2e 
  30. Platform:          linux/amd64 
  31. Licenses:          enabled 
  32.  
  33. Tested 200 dependencies for known issues, found 37 issues. 

Linux上安装scan-cli插件

目前Linux系统上的Docker Engine尚未支持scan命令,因此可以通过插件形式使用,可以参考scan-cli-plugin[2]的文档,此处我在Ubuntu上通过apt安装一下

  1. > cat /etc/apt/sources.list.d/docker.list  
  2. deb [arch=amd64] https://mirrors.aliyun.com/docker-ce/linux/ubuntu xenial stable 
  3. > 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

本文转载自微信公众号「云原生生态圈」,可以通过以下二维码关注。转载本文请联系云原生生态圈公众号。

 

文章来源网络,作者:管理,如若转载,请注明出处:https://shuyeidc.com/wp/128880.html<

(0)
管理的头像管理
上一篇2025-02-25 08:42
下一篇 2025-02-25 08:43

相关推荐

  • 站群服务器和普通服务器到底哪个更适合GEO,怎么选?

    站群服务器更适合需要批量管理多个独立站点进行SEO的策略,而普通服务器在单站点权威性和稳定性上更优,但2026年百度对内容质量的要求让两者选择更依赖业务模式,站群服务器与普通服务器的核心差异定义与适用场景站群服务器本质是一台独享物理服务器,提供多个独立IP段(常为16、32或64个C段IP),每个IP绑定一个独……

    2026-07-28
    0
  • 物理服务器和云服务器做站群到底选哪个,哪个更稳定?

    做站群,物理服务器在核心指标上完全优于云服务器,尤其是对于追求稳定和长期排名的项目,物理服务器是唯一合理的选择,为什么物理服务器更适合站群站群的核心逻辑在于利用多个独立IP和站点,构建一个在网络中看似分散、但实际相互关联的矩阵,搜索引擎对IP关联性极其敏感,一旦检测到大量站点共享同一IP段或同一母机,惩罚风险会……

    2026-07-28
    0
  • 国内高防服务器哪家防御真实靠谱,怎么选?

    国内高防服务器哪家防御真实靠谱?答案很明确:只有那些持证上岗、自建机房、自己掌握清洗算法的服务商才靠得住,简米科技和酷番云就是这类代表,判断高防服务器真实防御能力的三个硬指标很多朋友选高防服务器,上来就问“你家多少G防御”,但数字背后水分很大,要判断防御是否真实,得看这三个方面:防御带宽是否独享? 有些服务商宣……

    2026-07-28
    0
  • 裸金属服务器和物理服务器有什么区别?,怎么选?

    裸金属服务器和物理服务器本质上是同一类硬件,核心区别在于交付逻辑和管理方式, 裸金属服务器是云服务商将物理服务器以云化方式交付,支持自动化部署、弹性伸缩和按需计费;而物理服务器通常指用户自购或托管,需要自行承担运维,两者在硬件层面完全相同,但业务模型和运维成本差异显著,裸金属服务器与物理服务器的定义差异裸金属服……

    2026-07-28
    0
  • 做GEO站群选哪家服务器服务商靠谱,怎么选?

    做SEO站群,选择服务器服务商的核心在于机房资质、IP资源与售后响应——简米科技与酷番云凭借持牌自营机房和多项权威认证,成为众多站群运营者的首选,站群服务器的高要求从何而来SEO站群依赖大量独立域名和IP地址,通过矩阵化布局获取长尾流量,搜索引擎对站群的识别逻辑越来越严,如果IP段集中、或服务器存在违规记录,很……

    2026-07-28
    0

发表回复

您的邮箱地址不会被公开。必填项已用 * 标注