Skip to main content
LowSupply chainOWASP A05:2021CWE-540

How to fix: Gradle dependency lockfile exposed

The response is a Gradle dependency lockfile, served directly over HTTP. It is identified by Gradle's generated banner, or by lines in the group:artifact:version=configurations form.

Why it matters

Each line names a resolved JVM coordinate and the configurations it belongs to, so the file separates runtime dependencies from compile-only and test ones. That tells an attacker exactly which libraries are loaded in the running process, which is the set worth checking for a deserialization or expression-language vulnerability.

Dependency locking is a Gradle feature you have to opt into, so a project that has one is usually one that cares about reproducible builds. The lockfile still has no business being served: it is a build input, and the only thing publishing it changes is how quickly someone else can enumerate your JVM stack.

How to fix it

  1. 1Exclude gradle.lockfile, gradle/ and build files from the deployed artifact; ship the built JAR or WAR, not the project directory.
  2. 2Block lockfile paths at the reverse proxy.
  3. 3Run a dependency check against the locked coordinates, since the list is now known.

Code examples

Check the coordinates for known issues

bash
./gradlew dependencyCheckAnalyze

# or, with OSV
osv-scanner --lockfile gradle.lockfile

Apache: deny build files

APACHE
<FilesMatch "^(gradle\.lockfile|build\.gradle(\.kts)?|settings\.gradle(\.kts)?)$">
    Require all denied
</FilesMatch>

References

Detected automatically by VulnRadar. The check id is supply-chain-gradle-lockfile-exposed, stable across every scan so you can filter or diff on it.

See every supply chain check

Questions

How severe is Gradle dependency lockfile exposed?
VulnRadar rates this low severity in the supply chain category. The severity is fixed per check, not scored per site, so the same finding is the same severity on every scan.
Does VulnRadar check for this automatically?
Yes. It runs as part of every scan under the check id supply-chain-gradle-lockfile-exposed, which stays the same between runs so you can filter, diff, or gate CI on it.
Which standards does Gradle dependency lockfile exposed map to?
It maps to CWE-540. In the OWASP Top 10 it falls under A05:2021.

Missing a check?

The detection set is open. If you know a misconfiguration this does not catch, propose it: the issue template asks for the threat model, how to detect it, the false-positive risk, and a test fixture, which is the same thing a maintainer would have to work out anyway.

Propose a checkHow a check is built

Scan your own site for gradle dependency lockfile exposed

VulnRadar runs this check and hundreds more against a URL in seconds. No agent to install, just paste a URL.

Or scan this site as a demoRead the docs

How to fix: Gradle dependency lockfile exposed | VulnRadar