Skip to content

Lesson 14 of 14 · 24m

Maven, Gradle, and the Supply Chain You Actually Run

The resolved graph vs. the pom, dependency confusion, fractureiser's jar-infection lesson, and the SBOM that answers 'are we affected'.

Your deployable jar isn't built from your code — it's built from your code plus two hundred jars you never looked at, resolved transitively from a graph you didn't draw. When a CVE lands in log4j-core or jackson-databind, the question that actually decides your weekend is: which resolved version is in the artifact? Answering that is a build skill, not a security skill.

Read the resolved graph, not the pom

The pom.xml you wrote lists direct dependencies; the ones that ship are the resolved tree — every transitive pull, every version conflict Maven settled by picking the nearest declaration:

mvn dependency:tree -Dincludes=com.fasterxml.jackson.core:jackson-databind
./gradlew dependencies --configuration runtimeClasspath | grep jackson-databind

Maven's nearest-wins resolution is silent: two libraries wanting different jackson-databind versions get one — whichever sits closer in the graph — and the loser fails at runtime, with a NoSuchMethodError, on a deploy. Pin the version you actually want in dependencyManagement, or import the BOM that manages it for you (spring-boot-dependencies is the standard one). Gradle's answer is dependency locking — --write-locks writes gradle.lockfile, the resolved graph becomes a reviewable file, and the next build can only resolve what the lockfile allows.

libs.versions.toml (Gradle version catalogs) and Maven's <dependencyManagement> block exist for the same reason: one place where versions live, so a bump is a one-line diff and not a grep across forty modules.

Dependency confusion, and the jar that infects other jars

In February 2021 Alex Birsan published the attack: internal package names — auth-client, payments-core — leaked from private repos, and the same names published to public registries won resolution because Maven and npm query public repositories for missing names. He made $130,000+ in bug bounties proving that builds pulled his code. The fix is structural: an internal repository proxy (Nexus, Artifactory) that never forwards your private group IDs to Maven Central, plus reserved namespaces. The fix is not "be careful with names."

And then there's fractureiser — June 2023, Minecraft mods on CurseForge and BukkitDev shipping a stage-0 JAR that downloaded a second stage and rewrote every .jar on the filesystem into carriers. A jar is code, not data; provenance is the control. That is the same reason "it came from Maven Central" is a statement about transport — HTTPS is forced — not about trust.

Tooling that earns its keep

  • OWASP Dependency-Check or a hosted scanner maps your resolved graph to the CVE database — run it in CI against the resolved tree, not the pom.
  • CycloneDX Maven/Gradle plugins emit an SBOM; when the next Log4Shell lands, the SBOM answers "are we affected" in a query, not an audit.
  • Dependabot/Renovate turn version bumps into PRs with changelogs attached — the boring version of supply-chain security is a small diff merged often.
  • maven-enforcer-plugin's requireUpperBoundDeps fails the build on the silent version conflict instead of the deploy.

The honest version of "pin everything": pins rot. The discipline is small diffs merged often — a quarterly catch-up upgrade is a bigger risk surface than the weekly bump PR, because the catch-up is the one you can't bisect when it breaks.

Try this

Run mvn dependency:tree on the service you own and find one artifact resolved at a different version than you expected. Then check ~/.m2/settings.xml (or your CI's) for the repository list — if a private group ID can resolve against repo.maven.apache.org, that's the confusion path.

Pitfalls

  • mvn install builds against ~/.m2 cache — a poisoned local artifact wins silently; CI from a clean cache catches it.
  • Signing: Central artifacts carry GPG signatures but Maven doesn't verify them by default — signature verification is opt-in, so "signed" describes the file, not your build.
  • A version range ([1.0,2.0)) means your build can change on a Tuesday without a code change; pin.

Was this lesson helpful?

Sign in to rate

Keep reading

Related articles from the SudoSecurity blog.