DEV Community

Advait Patel
Advait Patel

Posted on

Your Docker Images Have 847 Vulnerabilities (And You'll Ignore Them All)

I ran Trivy on a production Node.js application last week. The output was 847 vulnerabilities. Not a typo. Eight hundred and forty-seven.

I stared at my terminal for a solid minute. Where do you even start with that? Which ones matter? Which ones are in libraries I'm not even using? Which ones have known exploits versus theoretical risks?

So I did what every developer does. I ignored all of them and shipped the image anyway.

vulnerabilities warnings

The CVE Fatigue Is Real

Security scanners are doing their job. They're finding vulnerabilities. The problem is they find ALL the vulnerabilities and dump them in your lap with zero context.

Here's what a typical scan looks like:

$ trivy image myapp:latest

Total: 847 (UNKNOWN: 23, LOW: 421, MEDIUM: 267, HIGH: 118, CRITICAL: 18)
Enter fullscreen mode Exit fullscreen mode

Okay, 18 critical vulnerabilities. That sounds important. Let me check them:

  • CVE-2023-12345 in libssl1.1 (7.5 severity)
  • CVE-2023-23456 in apt (9.8 severity)
  • CVE-2022-34567 in systemd (8.1 severity)
  • ...15 more critical issues

Cool. Now what? Do I need to fix all 18? Are they exploitable in my container? Is systemd even running in my container? I have no idea.

The Scanner Doesn't Know Your Context

Traditional scanners are like having a hypochondriac friend Google your symptoms. "You have a headache? Could be a brain tumor, meningitis, or 47 other deadly conditions."

Thanks, very helpful.

The scanner doesn't know:

  • If you're actually using the vulnerable code path
  • If the vulnerability is exploitable in a container environment
  • Which fixes won't break your application
  • What the actual risk is for YOUR specific use case

So you end up with three choices:

  1. Fix everything (impossible, takes weeks)
  2. Fix nothing (risky, but honest)
  3. Fix the ones that "feel" important (guessing)

Most of us pick option 2 or 3.

What If The Scanner Could Actually Think?

I got tired of this problem. I wanted a scanner that could:

  • Look at my Dockerfile and understand my setup
  • Tell me which vulnerabilities actually matter
  • Explain the issues in plain English, not CVE-speak
  • Give me specific fixes for my exact configuration

So I built it. It's called DockSec - https://owasp.org/www-project-docksec/, and it combines traditional security scanners with AI to give you context-aware analysis.

Here's what the same scan looks like with DockSec:

$ docksec Dockerfile -i myapp:latest

🔍 Analyzing security posture...
⚠️  Security Score: 42/100

Critical Issues (3 need immediate attention):
  • Running as root user (Dockerfile line 8)
    Why it matters: Root access in containers = full system compromise
    Fix: Add 'RUN useradd -m appuser && USER appuser' before CMD

  • Hardcoded AWS credentials (Dockerfile line 15)
    Why it matters: Credentials exposed in image layers, accessible to anyone
    Fix: Use Docker secrets or environment variables at runtime

  • Base image ubuntu:18.04 has 12 HIGH/CRITICAL CVEs with known exploits
    Why it matters: Your base layer has unpatched vulnerabilities
    Fix: Update to 'FROM ubuntu:22.04' (tested compatible with your deps)

📊 Full report saved to: myapp_report.html
Enter fullscreen mode Exit fullscreen mode

Now we're getting somewhere.

How It Actually Works

DockSec doesn't replace Trivy or Hadolint. It wraps them and adds an AI layer that:

  1. Runs all the traditional scanners (Trivy, Hadolint, Docker Scout)
  2. Analyzes your Dockerfile to understand your setup
  3. Correlates vulnerabilities with your actual usage
  4. Prioritizes what matters for YOUR application
  5. Generates specific, actionable fixes

flowchart showing AI analysis

The key difference: it reads your Dockerfile. It knows you're running Node.js. It sees you're using Ubuntu 18.04. It notices you're running as root. It understands the context.

A Real Example

Let's say you have this Dockerfile:

FROM ubuntu:18.04

# Install Node.js
RUN apt-get update && apt-get install -y nodejs npm

# Copy application
WORKDIR /app
COPY package*.json ./
RUN npm install
COPY . .

# Run application
EXPOSE 3000
CMD ["node", "server.js"]
Enter fullscreen mode Exit fullscreen mode

Traditional scanner output:

  • 156 vulnerabilities in Ubuntu 18.04
  • 89 vulnerabilities in various npm packages
  • Hadolint warnings about apt-get cache
  • Docker Scout findings about base image

You're left to figure out which of these 245+ findings matter.

DockSec output:

  • Update base image to ubuntu:22.04 (fixes 127 CVEs at once)
  • Add non-root user (prevents privilege escalation)
  • Pin npm packages (ensures reproducible builds)
  • Clean apt cache (reduces image size by 89MB)

Four actionable items. That's it. That's what actually matters.

The Privacy Angle

Before you ask: "Are you sending my code to OpenAI?"

No. DockSec sends the scan results and Dockerfile to the AI for analysis. Not your application code. Not your secrets. Just the configuration and findings.

And if you're paranoid (which is fair), you can use Ollama to run everything locally. No cloud AI needed.

# Run DockSec with local Ollama
export LLM_PROVIDER=ollama
export LLM_MODEL=llama3.1
docksec Dockerfile
Enter fullscreen mode Exit fullscreen mode

Everything stays on your machine.

Try It Yourself

Installation takes 30 seconds:

pip install docksec
export OPENAI_API_KEY="your-key"  # or use Ollama locally
docksec Dockerfile
Enter fullscreen mode Exit fullscreen mode

Scan one Dockerfile. See what it finds. I bet you'll be surprised.

before vs after comparison

The tool is open source (MIT license), has 14,000 downloads, and was recently adopted by OWASP as an incubator project. It's not perfect, but it's better than ignoring 847 vulnerabilities.

What's Next

This is article #1 in a series about Docker security and DockSec. Coming up:

  • How DockSec actually works under the hood
  • Running AI security scans completely offline
  • Real examples of fixing vulnerable images
  • Integrating security into CI/CD without slowing down deployments

If you try DockSec, let me know what you find. Star the repo if it helps you: https://github.com/advaitpatel/DockSec

Now go scan something. You might be surprised what's lurking in your images.

Top comments (0)