이미지 취약점 검사를 위해 사용하는 툴은 clair 혹은 trivy입니다.
이런식으로 라이브러리에 따른 취약점 CVE 항목과 심각도를 알려줍니다. 이를 통해서 이미지 취약점을 보다 쉽고 명확하게 확인할 수 있습니다.
기본적으로 trivy를 통해서 이미지 취약점 검사를 진행할 수 있습니다.
일단 실행 중인 pod의 이미지에 대한 취약점 검사를 진행하는 경우가 많기 때문에 이미지를 검색해줍니다.
kubectl describe deployment web1 -n applications | grep -i images
이미지를 찾았다면 trivy 명령어를 통해서 취약점 검사를 진행하면 됩니다.
# trivy가 깔려있는 경우
trivy image nginx:1.18-alpine
# docker로 취약점 진단하는 경우 (trivy가 안깔려있다면)
docker run ghcr.io/aquasecurity/trivy:latest image nginx:1.18-alpine
grep 명령어를 통해서 특정 취약점에 대한 정보를 바로 확인할 수도 있습니다.
trivy image nginx:1.19.1-alpine-perl | grep CVE-2021-28831
30.57 MiB / 30.57 MiB [-------------------------------------------------------------------------------------------------------------------] 100.00% 25.11 MiB p/s 1s
| busybox | CVE-2021-28831 | | 1.31.1-r9 | 1.31.1-r10 | busybox: invalid free or segmentation |
| ssl_client | CVE-2021-28831 | HIGH | 1.31.1-r9 | 1.31.1-r10 | busybox: invalid free or segmentation |