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
- Install the ntfy app on your phone (Android or iPhone).
- 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. - 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.
It's a good start, but know what it misses:
- It can take days for a new bug to reach CISA's list.
- It can't tell whether anyone can reach the container, so a database that only your other containers talk to looks as urgent as your public website.
- It only looks at the image. An app that updates itself in a volume, like WordPress, can be on a different version.
- If the script breaks, you hear nothing, and that looks the same as having no bugs.
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:
- Start it:
mkdir exploitwatch && cd exploitwatch curl -fsSLO https://github.com/marioleal/exploitwatch/releases/latest/download/compose.yaml docker compose up -d - Open
http://<your host>:7744and set a password with the setup code fromdocker compose logs exploitwatch | grep setup. - On the Settings page, add
ntfy://your-long-random-topicas a notification link and send a test. - 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:
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.