SSerguey Asael Shinder
Java coding notes: the JVM, and writing software that lasts

Serguey Asael Shinder: Building a dependency is running it, unless the toolchain says otherwise

· by Serguey Asael Shinder / Serguey Shinder

On 10 November the Go team shipped Go 1.27.4 and 1.26.11. The release history calls them security releases, and the Go vulnerability database lists twelve entries for them. Eleven are not about the standard library at all. They are about the toolchain, and their titles read like a catalogue of ways a package being built could make the build do something else: unexpected code execution via escaped quotes in //go:cgo_ldflag, linker flag injection through //go:cgo_* directives, .syso files disguised as Go object files, a #cgo pkg-config: directive that bypassed flag sanitisation, GCC spec files picked up from linker search directories, and a list of compiler options from --sysroot to Clang's -gen-*.

What these share is the moment they happen. Not when your service runs, but when a dependency is compiled, on a developer laptop or in CI, with whatever credentials that machine holds. The entry titles talk about sanitisation and injection, which tells you the toolchain filters what those directives may pass on. Eleven ways around that filter in one release show how much surface it has to cover.

Java has the same moment, and I think it is easy to forget it is there. Annotation processors are code from your dependencies that javac executes during compilation. The javac documentation for Java SE 25 is explicit about when that happens. Processing "is requested by using an option to configure annotation processing", such as -processor, --processor-path or --processor-module-path, "or by explicitly enabling processing with the -proc:full or -proc:only options". The description of -proc adds: "If this option is not used, annotation processing and compilation are done if at least one other option is used to explicitly configure annotation processing." And -proc:none turns it off.

So under SE 25, a processor sitting on the class path in a jar does not run just because it is there. Someone has to ask. That is the opposite default to the one that makes the Go fixes necessary: in Go the build reads directives from the package being built and has to sanitise them; in javac the build runs foreign code only when the build configuration names it.

Serguey Asael Shinder: Building a dependency is running it, unless the toolchain says otherwise
Building a dependency is running it, unless the toolchain says otherwise — Serguey Asael Shinder

Two practical consequences follow.

First, the configuration is now the security boundary, so read it as one. In a Maven or Gradle build, the list of annotation processors is a list of programs that run with your build's permissions. A dependency upgrade that adds a processor is a change to what your CI executes, and it deserves the same review as a new plugin.

Second, if a build needs no processing, say so with -proc:none. The documentation already makes the default narrow, but an explicit flag survives a later change to the tool, the build script or the defaults, and it makes the intent visible to the next person who reads the file.

The Go releases are a reminder that a safe build is something a toolchain has to work to keep. In Java, the closest we get is a default that keeps foreign code out until asked. It is worth knowing exactly where in your build the asking happens.