Safeguard
Developer Tools•

Should I review Gradle convention plugins and buildSrc like app code?

Yes. Gradle buildSrc and build-logic hold code that runs in every build with direct access to the Gradle API. Here is how to review and protect it.

Safeguard Security Team
4 min read

Yes. Convention plugins, buildSrc and build-logic are code that runs on every developer machine and CI job, with direct access to the Gradle API. A change there can alter repositories, versions and tasks for the whole build. Give those directories the same review rules, owners and scanning as application code.

What these pieces are

Gradle's docs describe convention plugins as build script files, such as a java-common-conventions file, applied as plugins in subprojects. They hold shared dependencies and configuration so a change is made once.

buildSrc is a special directory in the root project. Gradle treats it as an independent build, compiles it before evaluating other build scripts, and puts its compiled classes on the classpath of all build scripts. Only one is allowed per multi-project build.

build-logic is a standalone build, usually a directory of that name, included through the settings file. It does the same job as buildSrc through a different door.

Why this deserves review

Because the code is shared by every subproject, it is an efficient place to hide a mistake or a malicious change. A single edit can add a repository, loosen a dependency rule or add a task that runs on every build. The Gradle docs also advise against cross-project configuration with allprojects and subprojects because it hides injected logic, and suggest convention plugins instead. That is good for clarity, and it also gives you one place to watch.

Controls to add

  1. Code owners. Assign a small group as required reviewers for buildSrc, build-logic and the settings file.
  2. No silent repository changes. Flag any diff in these directories that touches a repositories or pluginManagement block.
  3. Pinned versions. Pin the plugins and libraries that build logic itself depends on, and lock or verify them.
  4. Scan it. Build logic has its own dependencies. Include the directory in dependency scanning and SBOM generation so those components are not invisible.
  5. Keep it boring. Avoid network calls, file writes outside the build directory, and reading secrets in build logic unless there is a documented reason.
  6. Test changes in a throwaway branch with a clean cache before merging.

What to look for in a diff

Diff patternQuestion to ask
New repository URLWho owns it, and is it filtered to specific groups?
New plugin or classpath entryWho maintains it, and why is it needed?
Exec, download or file write codeDoes it need to run on every build?
Version loosened to a range or plusWhy is the pin being removed?
Credentials or environment readsWhere do they go?

A note on speed

The docs mention that changes to buildSrc invalidate the configuration phase and force all tasks to re-execute. Some teams prefer build-logic partly for that reason. Whichever you choose, the review rule is the same.

For the plugin source question, see where Gradle plugins come from, and for subproject coverage, scan Gradle multi-project builds subproject by subproject.

Try it yourself

Click through it at your own pace, or open it full screen.

Open a finding and see how a code scanner points to the line. Build logic is code too, so it can be scanned the same way.

Safeguard's SBOM and dependency scanning can cover build logic dependencies, and the free scan at gold.safeguard.sh/scan is a quick way to see what a repository declares.

Quick check

Is build-logic safer than buildSrc?

Not inherently. Both are code that shapes the whole build. The Gradle docs present buildSrc as the primary approach and build-logic as an alternative, so choose on structure and speed, then review either one.

Do build logic dependencies show up in an SBOM?

Only if your scanner reads those directories. Check that buildSrc or build-logic is in scope.

Sources

Last reviewed: 19 October 2026.

Never miss an update

Weekly insights on software supply chain security, delivered to your inbox.

Self-healing security runs on Safeguard.

Your first fix PR is minutes away.

No sales call required, even your agent can complete the purchase over MCP.