Vulnerability scanning
Scan container images for known CVEs with Trivy on every server, read the findings, and block updates that would bring in critical vulnerabilities.
Kowan scans images for known vulnerabilities with Trivy and can block an update when the new image is riskier than you accept. Scans run on the server that holds the image, so they work the same on every host and need nothing installed on the Kowan server.
How a scan works
When you scan an image, Kowan starts a short-lived Trivy container on the image's host, through the same connection it uses for everything else on that host (the local Docker socket or the agent).
- Trivy reads the image straight from the host's Docker daemon, through a read-only socket. Nothing is pulled from a registry, so images built on the host can be scanned too.
- Trivy's vulnerability database is kept in a named volume,
kowan-trivy-cache, on each host. The first scan on a host pulls the Trivy image and downloads the database, so it takes longer and the host needs to reach them. Later scans reuse both. - One scan runs at a time per host. The scan container is removed when it finishes.
- Kowan runs Trivy's vulnerability scanner only. It does not look for secrets or misconfigurations.
Results are stored per image ID:
- A result younger than 24 hours is reused for the same image, also when it runs on another host.
- A failed scan never replaces an earlier good result.
- Up to 1000 findings are kept per image, most severe first. The severity counts are always exact.
Scan an image
- Go to Images and open an image.
- In the Vulnerabilities section, click Scan now.
Re-scan runs a new scan even when a result younger than 24 hours exists. A container's page shows the same Vulnerabilities section for the image it runs. Starting a scan needs the operator role.
Kowan scans when you ask, and when a scan gate needs a result before an update.
Read the results
Each finding has a severity: critical, high, medium, low or unknown.
- In the Images list, the Vulnerabilities column shows short chips such as
C 2andH 5,cleanwhen nothing was found,scanningwhile a scan runs andscan failedwhen it did not complete. Sort by the column to bring the worst images to the top. - The Vulnerabilities section of an image shows the Trivy version, when the image was scanned, the number of findings and how many have a fix. Below it, a searchable table lists each finding with its ID, Package, Installed version, Fixed in version and Severity.
A finding with a Fixed in version goes away once the image ships that package version. See Image updates to roll out a newer image.
Block risky updates
A scan gate scans the new image before an update switches to it, and blocks the update when the result is not acceptable. It applies to the Update buttons and to auto-update policies in apply mode.
| Gate | Label value | Blocks when |
|---|---|---|
| Never block | never |
Never. No scan is run for the gate. This is the default. |
| Block on critical | critical |
The new image has any critical vulnerability |
| Block on critical or high | high |
The new image has any critical or high vulnerability |
| Block if worse than current | worse |
The new image has more critical, or more high, vulnerabilities than the current one. Without a scan of the current image, only critical vulnerabilities block. |
Set the gate in one of three places. The first one that is set wins:
- The
kowan.scan.blocklabel on the container. - Scan gate in the auto-update policy of the container or deployment.
- Default scan gate in Automation → Auto-update (admins).
services:
api:
image: ghcr.io/example/api:2.4
labels:
kowan.scan.block: high
When the new image cannot be scanned, the gate blocks the update for every setting except Never block.
A blocked update leaves the running container untouched. It is recorded in the auto-update history and raises a warning alert in the bell and on your notification channels, unless the container has the label kowan.notify=off.
See vulnerabilities in the digest
The periodic digest lists images with critical or high vulnerabilities, so you do not have to check each host.
Configuration
These environment variables of the Kowan server change how scans run. See Configuration for the others.
| Variable | Default | Purpose |
|---|---|---|
KOWAN_TRIVY_IMAGE |
aquasec/trivy:0.75.0 |
The Trivy image, for example from a registry mirror |
KOWAN_TRIVY_CACHE_VOLUME |
kowan-trivy-cache |
The volume that holds Trivy's database on each host |
KOWAN_TRIVY_CONTAINER_PREFIX |
kowan-trivy- |
The name prefix of the scan containers |
API
| Method and path | What it does |
|---|---|
GET /api/v1/hosts/{hostID}/images/{id}/scan |
The latest result with its findings, and whether a scan is running |
POST /api/v1/hosts/{hostID}/images/{id}/scan |
Start a scan in the background. {"force": true} re-scans a fresh result. |
GET /api/v1/hosts/{hostID}/scans |
The latest result for every image on the host |
{id} is an image ID (sha256:...) or a reference without a /. For a reference that contains /, pass _ as the ID and the reference as ?image=<ref>. See REST API.