exploitwatch

How to get CVE alerts for your Docker containers on your phone

A CVE is a publicly known security bug. Your containers can have hundreds of them, and most don't matter to you. The ones worth a message on your phone are the bugs that attackers are already using.

Here are two free ways to get those alerts with ntfy, a push app that needs no account. The first is a short script. The second is exploitwatch, which is the tool this site is about.

Set up ntfy

  1. Install the ntfy app on your phone (Android or iPhone).
  2. Subscribe to a topic with a long random name. Anyone who knows the name can read your alerts, so don't pick something like docker.
  3. Send yourself a test from the Docker host:
    curl -d "It works" https://ntfy.sh/your-long-random-topic

Option 1: a script with Grype

Grype is a free scanner that lists the known bugs in an image. It also marks the ones on CISA's list of exploited bugs, so a script can skip the rest.

Install Grype and jq, then save this as docker-cve-check.sh with your own topic in it:

#!/bin/sh
# Sends a push for each running container with a bug that attackers are known to use.
PATH=/usr/local/bin:/usr/bin:/bin
TOPIC="https://ntfy.sh/your-long-random-topic"
SEEN="$HOME/.docker-cve-seen"
touch "$SEEN"

docker ps --format '{{.Names}}' | while read -r name; do
  image=$(docker inspect --format '{{.Image}}' "$name")
  grype "docker:$image" -q -o json </dev/null |
    jq -r '.matches[]
      | select((.vulnerability.knownExploited // []) | length > 0)
      | "\(.vulnerability.id) in \(.artifact.name) \(.artifact.version)"' |
    sort -u | while read -r bug; do
      grep -qxF "$name: $bug" "$SEEN" && continue
      curl -fsS -H "Title: $name has an exploited bug" -d "$bug" "$TOPIC" >/dev/null &&
        echo "$name: $bug" >> "$SEEN"
    done
done

Run it once by hand, then every morning with crontab -e:

0 8 * * * sh /path/to/docker-cve-check.sh

You get one push per bug and package, and the script remembers what it already sent. In a test with an old nginx:1.25.0 image it sent six, including one for the libwebp bug CVE-2023-4863.

Two ntfy messages from the script. Both say my-website has an exploited bug, followed by the CVE number, package and version.
What the script sends, in ntfy's web app.

It's a good start, but know what it misses:

Option 2: exploitwatch

exploitwatch was made to fill those gaps. It's free, open source and runs on one Linux Docker host. It checks about ten sources, works out who can reach each container and tells you what to do:

An exploitwatch alert in ntfy. P1, phpapp: php bug. php2shell: update to a PHP 8.4.27 image now. Why: Attackers are using this bug and phpapp is open to the internet. The package, CVE, image and exposure are listed below.
An exploitwatch alert for a made-up container.
  1. Start it:
    mkdir exploitwatch && cd exploitwatch
    curl -fsSLO https://github.com/marioleal/exploitwatch/releases/latest/download/compose.yaml
    docker compose up -d
  2. Open http://<your host>:7744 and set a password with the setup code from docker compose logs exploitwatch | grep setup.
  3. On the Settings page, add ntfy://your-long-random-topic as a notification link and send a test.
  4. Answer the questions on the Overview page. They tell it which containers are open to the internet, because Docker can't see your router.

Discord, Telegram, email and many others work too. The notification docs list the links.

Everything it finds is also in its web UI. You can look around in the live demo before you install it:

The exploitwatch Overview page with two P1 and two P2 alerts, each with what to do and why.

Which one to pick

Use the script if you have a few containers and none of them are open to the internet. Use exploitwatch if something you run is open to the internet, or if you want to be told what to do and not just the CVE number. If you want a full list of every CVE, run Grype or Trivy by hand.

Next: Is Watchtower enough to keep your containers safe?