Skip to main content

Company in a Box, Part 9 of 11: Patched images and vulnerability scanning

A series on building a company's IT with containers and open source

Running a company's IT means running its security too. A home lab is an easy place to skip that. "It's just at home." "It's behind the VPN." Famous last words, usually followed by a very educational weekend.

Inner Bits has a public website, inbound mail and a tunnel from the internet. It's meant to show what a small company could run. So it gets the treatment I'd expect at work: hardened containers, patched images, and scanning that happens whether I remember it or not.

The baseline: same rules for everyone

Every service in the Compose file merges a shared hardening block:

  • no-new-privileges, so a process can't climb its way up through setuid binaries;
  • a PID limit, so a fork bomb only blows up its own container;
  • a memory limit of about twice normal use.

On top of that: healthchecks on the databases and key services, databases never recreated unattended, and secrets passed in ways that don't show up in a process list. MariaDB's root password goes in through an environment variable and SQL over stdin, never on a command line where ps can read it out loud.

Patched images

The first daily image scan was humbling. Like stepping on the scales after the holidays.

Lots of popular images on Docker Hub are only rebuilt when the app has a new release. Between releases, the OS packages inside them go stale, and the CVE count quietly climbs.

So most images in the lab aren't used as published. A generic patched/Dockerfile takes the upstream image and applies its distro's pending security updates on top:

ARG BASE
FROM ${BASE}
ARG PATCH_DATE
RUN apt-get update && apt-get -y upgrade && rm -rf /var/lib/apt/lists/*

(The real one also handles Alpine, rebuilds the bundled gosu binary with a current Go, and can hold or remove specific packages and files.) Every night, every patched image is rebuilt with --pull and a new PATCH_DATE, so it picks up that day's fixes.

That PATCH_DATE taught me something about Docker's build cache. My deploy script built without setting it. With an empty value, the build matched an old cached layer, so every "rebuild" re-tagged an old, unpatched image as brand new. Everything looked fresh. Nothing was. Now the build refuses to run without it.

Patching has limits:

  • Images without a package manager (n8n, Keycloak, cloudflared) can't be patched this way.
  • CVEs in language packages (Go binaries, Java jars, npm, pip, Composer) only disappear when upstream rebuilds the app. A scanner saying "fixable" doesn't always mean fixable by you.

Scanner one: what's inside the images

The security-scan container runs daily at 05:00. Trivy scans every running image for HIGH and CRITICAL vulnerabilities, leaked secrets and misconfigurations. Docker Bench checks container settings against the CIS Docker benchmark. Results go to Loki and onto a Grafana dashboard.

The first baselines had dozens of critical CVEs, concentrated in a handful of images (HumHub, Open WebUI, phpMyAdmin, Dremio, iTop). Moving about twenty services to patched images, adding the hardening block everywhere and replacing a few apps brought that down a lot. What's left is mostly language packages waiting on upstream, plus some Docker Bench warnings that simply don't apply to Docker Desktop (there's no AppArmor or SELinux to configure).

Known false positives, like GitLab's test fixtures that look exactly like secrets, go into an allow list with a reason. They're still logged, just marked as allowed. Nothing quietly disappears.

Scanner two: what an attacker would see

Images are half the story. The other half is: what's actually listening, and what is it saying about itself?

I started with Greenbone (OpenVAS). It's thorough. It's also enormous, has its own users with no SSO, and keeps its reports in yet another web UI. It failed the SSO test from post 6, so it was voted off and replaced with a small container of my own, netscan. Once a week it:

  1. finds the host's Tailscale address and every container on the Docker network;
  2. runs Nmap with service detection and vulners CVE matching;
  3. runs Nuclei templates, minus anything intrusive, DoS-like or fuzzing (I want a scan, not an incident);
  4. sends every finding to Loki, labelled with the scan.

A Grafana dashboard (admins only) gives every finding a status:

  • open: go fix it;
  • backported: a CVE guessed from a distro-built service's version string. Ubuntu's OpenSSH 9.6p1 still says 9.6p1 long after Ubuntu has patched it, so these are mostly noise. Trivy, which reads the installed packages, has the final word there;
  • accepted: a known false positive or internal-by-design, listed in a file, with a reason.

The severity tiles only count open findings. That one choice turned the dashboard from something I scroll past into something I act on.

What the first real triage found

The first full triage looked terrifying: 68 critical, 176 high. Cue sweating.

Most of it was the same finding counted three times: once on the container, once on the host's published port, and once more through the Docker network's gateway (which is just the host again, wearing a hat). Add the backported noise, and the real list was short.

And the most important findings weren't in a container at all:

  • The UniFi Network Server, installed directly on the Windows host years ago, had a critical path-traversal vulnerability. CVSS 10. Upgraded across a major version the same day. I had completely forgotten it was even running.
  • Ollama, the local AI runtime, had "expose to the network" switched on, so its unauthenticated API was answering anything on my tailnet. It's now localhost-only. Containers still reach it through Docker's host gateway, and people reach the models only through the authenticated gateway in post 10.
  • Four admin ports that skipped Traefik and Keycloak (iTop, n8n, GitLab HTTP, the DNS console) were moved to 127.0.0.1.

The lesson I'd tattoo on every lab builder: scan the host, not just the containers. I'd been so careful with the containers. The forgotten Windows app was the one with a perfect 10.

Next: a private AI assistant. Local models, one authenticated gateway, and the company's own apps as tools.

Read next: Company in a Box, Part 10 of 11: A private AI assistant on local models

Comments

Popular posts from this blog

Company in a Box, Part 1 of 11: Why I'm building a company's IT with containers and open source

A series on building a company's IT with containers and open source Hi. I'm an IT admin. I've been doing this long enough to have strong opinions about Group Policy and long enough to have strong feelings about printers. For most of my career, my home lab looked exactly like my day job: a Hyper-V host and a handful of VMs. Each one had its own OS to patch, its own disk to grow, its own backup job, and its own creative way of breaking at 2 a.m. It worked. It also stopped teaching me anything. These days every vendor README starts with docker compose up , and I was still out here lovingly hand-crafting a VM for each one, like a medieval monk illuminating manuscripts. So I moved the lab to containers. Then things got slightly out of hand. A confession about who I am Let's get this out of the way, because it explains every decision in this series. I'm a Microsoft guy. Windows Server, Active Directory, Exchange, Hyper-V: that's my day job, and I'm good at...

Company in a Box, Part 11 of 11: What it costs vs. SaaS and the cloud

A series on building a company's IT with containers and open source Ten posts in, it's time for the question everyone skips to: is this worth it? Inner Bits runs a small company's IT on one desktop. What does that cost? What would the same company pay to rent it all as SaaS? And what if you ran the exact same stack on a rented server at Hetzner, OVH, Azure or AWS instead of under your desk? Get comfortable, there are tables. Three of them. What the lab costs to run All prices are what I pay in Portugal. Item Cost Hardware a ~€1,500 desktop (32 GB RAM, a GPU for the AI models); over five years, ~€25 a month Electricity ~€15–30 a month Domain name ~€1 a month (about €12 a year) Cloudflare ~€5 a month (Workers Paid; Tunnel, Email Routing and DNS are free) Stalwart Enterprise licence paid (see the ledger below) Tailscale free personal plan Software €0 for everything else. Every app is free software or a free community edition Total ro...