Skip to main content

Pregunta 21 | Escaneo Vulnerabilidades Imágenes

(puede resolverse en cualquier contexto kubectl)

El Escáner de Vulnerabilidades trivy está instalado en tu terminal principal. Úsalo para escanear las siguientes imágenes en busca de CVEs conocidos:

nginx:1.16.1-alpine

k8s.gcr.io/kube-apiserver:v1.18.0

k8s.gcr.io/kube-controller-manager:v1.18.0

docker.io/weaveworks/weave-kube:2.7.0

Escribe todas las imágenes que no contengan las vulnerabilidades CVE-2020-10878 o CVE-2020-1967 en /opt/course/21/good-images.


Respuesta:

La herramienta trivy es muy simple de usar, compara imágenes contra bases de datos públicas.

➜ trivy nginx:1.16.1-alpine
2020-10-09T20:59:39.198Z INFO Need to update DB
2020-10-09T20:59:39.198Z INFO Downloading DB...
18.81 MiB / 18.81 MiB [-------------------------------------
2020-10-09T20:59:45.499Z INFO Detecting Alpine vulnerabilities...

nginx:1.16.1-alpine (alpine 3.10.4)
===================================
Total: 7 (UNKNOWN: 0, LOW: 0, MEDIUM: 7, HIGH: 0, CRITICAL: 0)

+---------------+------------------+----------+-------------------
| LIBRARY | VULNERABILITY ID | SEVERITY | INSTALLED VERSION
+---------------+------------------+----------+-------------------
| libcrypto1.1 | CVE-2020-1967 | MEDIUM | 1.1.1d-r2
...

Para resolver la tarea podemos ejecutar:

➜ trivy nginx:1.16.1-alpine | grep -E 'CVE-2020-10878|CVE-2020-1967'
| libcrypto1.1 | CVE-2020-1967 | MEDIUM
| libssl1.1 | CVE-2020-1967 |

➜ trivy k8s.gcr.io/kube-apiserver:v1.18.0 | grep -E 'CVE-2020-10878|CVE-2020-1967'
| perl-base | CVE-2020-10878 | HIGH

➜ trivy k8s.gcr.io/kube-controller-manager:v1.18.0 | grep -E 'CVE-2020-10878|CVE-2020-1967'
| perl-base | CVE-2020-10878 | HIGH

➜ trivy docker.io/weaveworks/weave-kube:2.7.0 | grep -E 'CVE-2020-10878|CVE-2020-1967'

La única imagen sin ninguno de los dos CVEs es docker.io/weaveworks/weave-kube:2.7.0, por lo tanto nuestra respuesta será:

# /opt/course/21/good-images
docker.io/weaveworks/weave-kube:2.7.0