# 5. Perform Vulnerability Assessment on Docker Images

## 1. Vulnerability Assessment on Docker Images using Trivy <a href="#task-1-vulnerability-assessment-on-docker-images-using-trivy" id="task-1-vulnerability-assessment-on-docker-images-using-trivy"></a>

Trivy is a powerful security scanner that detects vulnerabilities and misconfigurations across a wide range of targets, including container images, file systems, Git repositories, virtual machine images, Kubernetes, and AWS. With its comprehensive scanners, Trivy identifies OS package vulnerabilities, sensitive information, IaC issues, and more, providing a robust security solution for your infrastructure.

In this lab we will be scanning two docker images, first the secure one and second the vulnerable one

```
docker pull ubuntu
```

Once the image is pulled we will be performing vulnerability assessment. Execute command **trivy image ubuntu**.

```
trivy image ubuntu
```

<figure><img src="https://2218819509-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FrUBnODuUX4EQ8P27uc5D%2Fuploads%2F1BtYVF2RXiWkrtLkclrM%2Fimage.png?alt=media&#x26;token=a0d9f5bb-b673-4f62-b649-356bbb7242cb" alt=""><figcaption></figcaption></figure>

We can observe that we have total **0** vulnerability and it's completely secure.

Now, let us pull a vulnerable image.

```
docker pull nginx:1.19.6
```

Execute command.

```
 trivy image nginx:1.19.6
```

<figure><img src="https://2218819509-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FrUBnODuUX4EQ8P27uc5D%2Fuploads%2FLodhkiZrxFCb2sTysKOJ%2Fimage.png?alt=media&#x26;token=5c15f4ab-fe3f-44c5-a8be-2de71bdac744" alt=""><figcaption></figcaption></figure>

We can see that we have total **401** vulnerabilities which is categorized as well along with **CVEs** mentioned.

{% embed url="<https://www.udemy.com/course/ethical-hacker-practical/?referralCode=289CF01CF51246BCAD6C>" %}
