All writing

Security · Backend Engineering

A Vulnerability Scanner Gave Me 198 Findings on One Service. There Were Really Two Causes.

What happened when I pointed Trivy at four production Spring Boot services that had never been scanned before: how 198 flagged findings on one service traced back to two root causes, which fixes were routine, which hit a hard wall, and the engineering judgment calls in between.

  • Trivy
  • Vulnerability Management
  • Spring Boot
  • Docker
  • Dependency Management
  • AWS
  • DevSecOps

Four production services. Never scanned for vulnerabilities, not because anyone decided against it, but because it had simply never been wired into the pipeline. I fixed that and pointed Trivy at the first one. It came back with 198 findings flagged HIGH or CRITICAL.

That number is designed to make you panic, or to make you numb — either react to 198 fires at once, or decide the tool is too noisy to take seriously and ignore it. Neither is the right response. Almost all 198 traced back to exactly two decisions made long before I ever ran a scan: one frozen Docker base-image tag, and one Spring Boot version pinned well past its own support window. Two root causes accounted for the overwhelming majority of that one service’s raw count — they weren’t the only problems I found across all four services, and the rest of this is as much about the genuinely separate issues underneath as it is about the two big ones.

If you’re about to run a scanner against a codebase for the first time, this is the part nobody tells you: the number on the summary line is almost never the number of problems you have.

The services, briefly

Four Java 21 / Spring Boot services, Docker-deployed on Kubernetes, built through the same CI pipeline family. I’m not naming the organization or the services — what matters here is the engineering, and it holds up without the names attached:

  • Two integration services (I’ll call them A and D) that talk to point-of-sale systems — nearly identical in shape, same base image, same framework version going in.
  • A shared platform layer (B) — five Gradle modules, three of them independently deployed.
  • A portal API (C) behind a customer-facing product.

All four went through the same sequence: wire the scan into CI in report-only mode first (no failing builds on day one — more on why below), read what came back, and fix what was worth fixing. Service A is where the 198 came from, and where I have the clearest before-and-after. The others follow the same reasoning, with their own evidence and their own gaps — more on exactly what’s confirmed and what isn’t further down.

Lesson one: separate “what Trivy scanned” from “what’s actually wrong”

Trivy runs two different scans, and mixing them up is the fastest way to misread your own results. trivy image looks at the built container — OS packages in the base image, plus whatever dependency files ended up in the final layer. trivy fs --scanners vuln,misconfig reads the source directly — your build files for dependency CVEs, your Dockerfile and Kubernetes manifests for misconfigurations like running as root. The misconfig checks only show up in the second scan, because they’re about how the image gets built, not what’s inside it. I ran both, against all four services, before each image push.

The other early decision: I didn’t let a failing scan fail the build. Not because the findings didn’t matter, but because a hard gate on the first ever run of a brand-new tool means the first thing anyone sees is a pipeline that’s been green for years suddenly blocked by 140 findings, with zero context, on whatever day the scan happens to land. I wanted to see the whole picture once, properly, before deciding what becomes a hard gate going forward.

Lesson two: count root causes, not CVE IDs

Service A came back with 140 OS-level findings and 58 application-dependency findings — 198 together. Read as a flat list, that’s two weeks of ticket triage. Read correctly, it’s two sentences:

The Dockerfile had FROM amazoncorretto:21.0.4 — a frozen tag that, not at all obviously from the name, resolves to an Amazon Linux 2 base image. AL2 hit end-of-life mid-2026. Trivy said so directly in its own output: “This OS version is no longer supported by the distribution.” Thirty-two packages carried those 140 CVEs between them, including tools like vim and python2 that the application never touches at runtime — they’re just inherited OS baggage nobody asked for. One unsupported operating system, counted 140 different ways.

The second number had a different, equally singular cause: the project was pinned to Spring Boot 3.3.0. Every flagged library in that pile except Spring Boot itself — Tomcat, Netty, Jackson — is a transitive dependency whose version Spring’s own dependency-management BOM decides for you. You don’t declare tomcat-embed-core in your build file; you declare a Spring Boot version, and Boot picks the Tomcat that comes with it. The entire 3.x line of Spring Boot has since moved past its open-source support window. One stale platform pin, expressed through three library names.

That’s 198 out of 198 explained by two decisions — for this one service. It doesn’t explain the leaked credential I found on a different service, or the handful of dependencies that weren’t part of either pattern, both covered later. The reframing still matters for the same reason either way: it changes what “fixing it” means. Fixing an unsupported OS is one line in a Dockerfile and a rebuild. Patching 58 flagged CVEs one dependency at a time would have taken a week and missed the actual lever.

The fixes, and the reasoning that mattered more than the diff

Pin the exact image tag, don’t float it. The fix for the EOL base image is moving to Amazon’s AL2023-based builds — but which tag matters more than it sounds. I almost reused amazoncorretto:21-al2023, the obvious-looking unpinned tag, until I checked what it actually resolves to and found that unsuffixed tags built before a certain cutover date silently point at AL2 — the exact problem I was trying to leave. I pinned an explicit patch version instead: amazoncorretto:21.0.13-al2023. A floating tag means two builds, same Dockerfile line, can silently pull different OS and JDK packages with nobody deciding anything changed. Bumping a pinned tag is a reviewed line in a pull request. Bumping a floating one is an accident you find out about later.

Go to the last stable release, not straight to the newest major version. Spring Boot 4.x is the actively-supported line, and it’s the only line with a real fix for the two CRITICAL findings I’ll get to below — but jumping a major version as a side effect of a vulnerability sweep is how you turn a Tuesday afternoon into a week of regression-hunting. I bumped to 3.5.16, the last release in the 3.x line, with its matching Spring Cloud train. That alone still left Tomcat, Netty, and Jackson a few patches short of their actual fixes, so three explicit overrides went on top of the Boot-managed defaults. I didn’t trust a successful compile as proof any of this worked — I ran ./gradlew dependencies afterward specifically to confirm the override versions actually land on the runtime classpath, because a declared override that silently loses to some other resolution rule is worse than no override at all; at least the second one fails loudly.

The actual payoff, confirmed by re-running the scan, not assumed: OS findings on Service A dropped from 140 to 18, all now HIGH with zero CRITICAL — and every one of those 18 showed an installed version exactly one patch behind its published fix, the normal signature of a supported OS with routine lag, nothing like the EOL pattern that produced 140. Jar findings dropped from 58 to 2. Service A has two deployable components sharing one base image and one dependency baseline; both landed on the identical 18-and-2 result, because a shared root cause produces a shared symptom — worth confirming once you’ve fixed the first one, rather than assuming, but not worth running the fix twice by hand.

What the re-scans actually showed, service by service

I don’t want to round this up into one tidy number, because the four services aren’t at the same point of verification. Here’s exactly what each one has behind it:

Service Layer Before After the fix What’s confirmed
A OS packages 140 (0 Critical / 140 High) 18 (0 Critical / 18 High) Re-scanned and confirmed — both deployable components
A App dependencies 58 (9 Critical / 49 High) 2 (2 Critical / 0 High) Re-scanned and confirmed; the 2 remaining need the major-version migration below
B OS packages 140 (0 Critical / 140 High), identical across its 3 modules Fix applied Not yet re-scanned
B App dependencies 60–65 per module (9–11 Critical / 51–54 High) Fix applied Not yet re-scanned
C OS packages No pre-fix scan exists 17 (0 Critical / 17 High) Fixes were applied before this service’s first-ever scan, so there’s no “before” number to show
C App dependencies No pre-fix scan exists 2 Critical remaining Same unresolved pair as A and B
D Dockerfile configuration 1 High, on an old Dockerfile that isn’t actually used 0 on the two Dockerfiles that are actually deployed Confirmed clean on what’s live; the flagged one was already dead code

Service A is the only one with a genuine before-and-after on the dependency and OS layers. B’s fix is applied but unconfirmed by a second scan. C never had a pre-fix baseline to compare against. D’s only confirmed re-scan evidence is the Dockerfile check, not the dependency layer. I’d rather show that unevenness plainly than imply a uniform result I can’t back up.

The two that didn’t move, and why that’s the right outcome

Two CRITICAL findings survived everything above, on all four services, and are still open today. Both sit inside the same part of Spring’s web framework — code that only runs if an application actually uses a specific, fairly uncommon rendering feature — and both have a fix published only in a newer major version of the framework than any of these services run. I checked NVD directly rather than trusting Trivy’s “fixed version” column at face value, and confirmed there’s no backport to the version line still in use; the fix genuinely requires the next major version of Spring Boot, not just a dependency bump.

So: not fixed, and the honest reason is that the only real fix is the major-version migration I’d already decided not to rush. What I could still do was check whether the vulnerable code actually runs here. I checked all four codebases for the specific usage patterns that would invoke that part of the framework and found none — every one of these services is a plain REST/JSON API, and none of them touches that corner of Spring at all. That’s not the same as the finding being fixed. It’s the difference between “there’s a loaded gun in the building” and “there’s a loaded gun in a locked room nobody has a key to” — still worth fixing properly, but not the same emergency, and that distinction is what actually determines how urgently the migration needs to be scheduled versus just tracked.

(I’m deliberately not naming the specific CVEs or the exact framework feature here. They’re public identifiers, but the findings are still unresolved in a live system, and writing a precise map of “here’s exactly what’s vulnerable and exactly how I confirmed it can’t currently be reached” is a more detailed target than this post needs to hand anyone. The engineering lesson — presence on the classpath isn’t the same risk as a reachable code path — doesn’t need the specifics to land.)

The failure that only showed up after everything looked fine

This is the part I’d tell someone to pay the most attention to. One module, after the exact same version bump described above, compiled cleanly — ./gradlew build green, no warnings. It failed on startup instead, inside Spring’s own compatibility-verification check, which only runs when the application context actually initializes. A clean build had told me nothing useful. Only running the thing (./gradlew bootRun) surfaced that this particular module had never imported the Spring Cloud BOM at all, and had an explicitly hand-pinned library version fighting the new Boot version underneath it. The fix — add the missing import, stop pinning the library so the BOM manages it — took five minutes once I knew what was wrong. Finding out took actually running the service, which a compiler will never do for you.

A second, smaller version of the same lesson: one service’s build broke because a class imported org.apache.commons.io.IOUtils directly, using a library that had been arriving transitively through another dependency until the version bump reshuffled the dependency graph and it quietly stopped showing up. Not a vulnerability, not even related to the scan — just a reminder that “bump the platform version” is never a pure security change. It’s a change to the whole shape of your dependency tree, and the only way to know what broke is to build and run the thing, not read the version diff and assume it’s fine.

Don’t trust the flag without reading the value

Two findings deserve a specific callout because they look identical to a real problem and are not. The first: a Kubernetes ConfigMap flagged for storing a key literally named token. I read the actual value before doing anything about it — it was a static OAuth endpoint path, not a credential. Trivy’s check keys on the field name, not the content, so it has no way to tell token: "the actual secret" apart from token: "https://api.example.com/oauth/token". Worth confirming once and recording clearly, so nobody “fixes” a URL six months from now because a scanner is still flagging it.

The second finding in that same category was real: a live OAuth client secret, committed in plaintext in a config file, shared across more than one environment. My first instinct was the standard playbook — rotate it, move it into the secret store that already existed for everything else, strip it from the config file. What actually happened, a day later, was better than my plan: the entire feature that secret belonged to got removed outright, taking the credential with it. Rotating a secret keeps the secret around in a safer box. Removing the feature removes the reason the secret needed to exist at all. I’d rather have found that solution first — I didn’t, and it’s a useful reminder that “rotate and relocate” is the reflexive answer, not always the best one, and it’s worth pausing to ask whether the thing holding the secret needs to exist before reaching for the secret-management playbook.

If you’re about to do this for the first time

A few things I’d tell someone running a first-ever scan against services that have been live for years:

  • Start report-only. You need to see the real shape of the problem before you decide what blocks a build. A hard gate on day one just teaches people to distrust the tool.
  • Group findings by root cause before you triage them individually. Ask “what one thing produced this many findings” before opening 50 tickets. Most of the time the answer is a base image tag or a platform version, not 50 separate bugs — but check that it actually explains everything before you assume it does.
  • A clean build is not validation. Running the thing is. The one failure that actually cost time in this whole effort was invisible at compile time and obvious the moment the application started.
  • Check whether the vulnerable code path is reachable before deciding how urgent a fix is. “On the classpath” and “in the request path” are different risk levels, and the scanner can’t tell you which one you have.
  • Read the value behind a flagged key before you act on the field name. Scanners match patterns, not meaning.
  • When a fix looks like “rotate the secret,” ask whether the thing using it should exist at all first.
  • Say plainly which fixes you’ve actually re-verified and which you haven’t. “Applied” and “confirmed” are different claims, and the gap between them is exactly where a tidy report stops matching reality.

The two unresolved findings here are still unresolved. That’s not a loose end I forgot to close — it’s the honest shape of the problem: some fixes are a line in a Dockerfile, and some are a major-version migration that deserves to be scoped, planned, and done properly rather than squeezed in because a scanner flagged it this week.