Join our Newsletter — 33% off our NHI Course
Home› FAQ› Cyber Security› What signs indicate a Java build is executing…
Cyber Security

What signs indicate a Java build is executing untrusted code during compilation?

← Back to all FAQ
By NHI Mgmt Group Editorial Team Updated October 12, 2026 Domain: Cyber Security

Unexpected subprocesses, outbound HTTP or TCP calls, unusual compiler log markers, and service-provider files inside dependency jars are all warning signs. If javac is spawning shells or contacting remote infrastructure, the build should be treated as an active compromise path, not a normal compile event.

What “untrusted code during compilation” looks like in a Java build

A normal Java compile should stay close to the compiler, the source tree, and the dependency cache. The warning signs in your answer point to something broader: code running during build time that is not just transforming sources, but behaving like an active payload. That can mean a malicious annotation processor, plugin, transitive dependency, or service-loaded class with enough execution path to reach the network, shell, or filesystem.

The practical test is not whether the build completes, but whether compilation is triggering behaviour that should not be needed to produce class files. If a build step starts spawning processes, making outbound calls, or emitting strange markers, treat that as execution with impact, not as a harmless compiler quirk.

Which signals matter most during a suspicious compile?

Unexpected subprocesses are one of the clearest indicators because javac and the surrounding build tool do not normally need a shell to compile code. A sudden fork to bash, sh, cmd.exe, PowerShell, or another interpreter suggests the build chain has moved from compilation into general-purpose execution.

Outbound HTTP or TCP traffic is equally important, especially if it targets unfamiliar hosts, cloud metadata endpoints, paste sites, or internal services not required for dependency resolution. During compilation, that kind of network activity often indicates staging, command retrieval, exfiltration, or a remote control channel rather than ordinary build telemetry.

Unusual compiler log markers are another useful clue because many malicious build-time payloads try to hide in normal output, suppress errors, or write distinctive strings that help the attacker confirm execution. These markers may also expose which phase was abused, for example an annotation processor, a Maven or Gradle plugin, or a service-provider hook loaded from a dependency jar.

Service-provider files inside dependency jars matter because Java’s service loading model can activate code without an obvious direct call site. A jar that contains unexpected META-INF/services entries may cause classes to be discovered and executed as part of compilation, especially when annotation processing or build plugins scan the classpath.

In practice, the presence of one signal should raise suspicion, but a cluster of them is stronger: build-time execution plus network activity plus odd logging is a compromise pattern, not a tool misconfiguration. That is why the right response is to inspect the execution path, not only the source file that happened to be compiling.

How compilation becomes an attack path in the Java toolchain

Java builds are attractive because compilation can load code from many places, not just the source being compiled. Annotation processors, bytecode generators, custom Maven or Gradle plugins, and service-loaded components can all run with the permissions of the build environment and inherit its access to repositories, secrets, caches, and internal networks.

That makes the build pipeline part of the attack surface. If an attacker can get malicious code into a dependency, a plugin, or a jar on the classpath, the compile step may become the point where the code first executes. From there, the payload can inspect environment variables, steal tokens, talk to external infrastructure, or tamper with build outputs before artifacts are published.

This is why build integrity controls and provenance checks belong in the same conversation as compiler telemetry. A suspicious compile is not just a malware symptom, it is a supply-chain event, because the attacker is abusing the trust placed in dependencies and build tooling. Guidance from SLSA is useful here because build provenance and artifact integrity are exactly the properties that help separate a clean build from a tampered one.

Risk and Threat Considerations

A compromised compile can expose source code, credentials, signing material, and internal services that were never meant to be reachable from a build step. The main danger is that the attacker does not need to wait for runtime exploitation, because the build itself becomes the execution environment.

Failure mechanism: A malicious or injected build-time component uses compiler hooks, service loading, or plugin execution to run arbitrary code, then reaches outward through subprocesses or network calls to stage, exfiltrate, or persist.

Impact: The result can be poisoned artifacts, stolen build secrets, compromised package publishing, or lateral movement from a developer or CI environment into wider infrastructure.

Standards & Framework Alignment

This section maps relevant standards and security frameworks to the operational risks and controls described in this guidance.

MITRE ATT&CK addresses the attack and risk surface, while SLSA, OWASP ASVS and CIS Controls v8 set the governance and control requirements practitioners need to meet.

FrameworkControl / ReferenceRelevance
SLSASupply-chain Levels for Software ArtifactsJava builds executing untrusted code are a build provenance and artifact integrity issue.
Recommendation — Require provenance and integrity checks for build inputs, plugins, and produced artifacts.
MITRE ATT&CKT1059 — Command and Scripting InterpreterUnexpected shells during compilation indicate script or shell execution from the build path.
T1105 — Ingress Tool TransferOutbound calls during compile can fetch payloads or stage additional tooling.
Recommendation — Hunt for shell execution launched by build processes and block nonessential interpreter use. Inspect build-time network egress for payload retrieval and staging activity.
OWASP ASVSV15 — Secure Coding and ArchitectureThe question concerns build-time code loading and architecture choices that allow unexpected execution.
Recommendation — Review build architecture for untrusted code paths and restrict executable build hooks.
CIS Controls v8CIS-16 — Application Software SecurityBuild tooling and dependencies are part of the software security control surface.
Recommendation — Verify build dependencies, plugins, and generated artifacts before release.

Practitioner Guidance

What to verify: Check whether the process tree, network destinations, and loaded classes match the expected build graph. If the compiler is the only expected Java process but you see shell children or outbound connections, treat that as an incident until explained.

Decision rule: If the suspicious activity occurs during dependency resolution, annotation processing, or plugin execution, prioritise containment and artifact quarantine before trying to prove malicious intent. By the time a build can phone home, it already has enough execution to change the trust posture of the output.

What good looks like: A clean build produces only the compiler and approved build tool processes, with network access limited to sanctioned repositories and no unexpected service-provider activation from third-party jars.

Practitioner takeaway: In Java pipelines, compiler time is execution time. If the build is doing things a compiler should not need to do, assume the trust boundary has already been crossed and investigate the entire build chain, not just the source file that was being compiled.

Free weekly newsletter

Subscribe to the NHI & AI Identity Journal

The latest on NHI and Agentic AI security – articles, research, breaches, news and events every week.

Bonus 33% off our NHI Course when you subscribe.

NHIMG Editorial Note
Reviewed and updated by the NHIMG editorial team on October 12, 2026.
NHI Mgmt Group — the #1 independent authority on Non-Human Identity, IAM, and Agentic AI security. nhimg.org