The build reads its package publish target from an environment variable with no checks. Change that variable and the publishing credentials go with it.
What goes wrong
The build picks its package publishing endpoint from an environment variable and uses it directly. No scheme validation, and no check that the address is the registry you actually publish to. Whoever can set that variable sets the destination.
The destination is where the damage lives. Publishing authenticates, so the configured username and secret get sent to whatever host the variable named. Redirect it to an attacker-controlled server and the build hands over its publishing credentials while it believes it is doing a normal release.
Build environments feel trusted, which is why this hurts. A malicious change to CI config, or a compromised dependency pulled into the build, can rewrite an environment variable, and the credentials follow the URL.
The pattern
publishTo(env.PUBLISH_URL) { // no validation
credentials {
username env.PUBLISH_USER
password env.PUBLISH_SECRET
}
}def target = env.PUBLISH_URL
assert isExpectedRegistry(target) // pinned host, https only
publishTo(target) {
credentials {
username env.PUBLISH_USER
password env.PUBLISH_SECRET
}
}Grounding and reachability were confirmed. The exploit-path gate would not conclude without the calling code, so the finding was held and an evidence request was raised instead of being reported as fact.
Why it matters to you
Credentials go wherever the URL points, and if the URL is a variable, someone can point it. Treat your release pipeline as an attack surface, because it holds secrets with real reach and it runs code from more sources than you track. Pin the publish endpoint to a known host, or at minimum assert its scheme and origin before any credential is attached.
Check your own code
- Find publish or upload steps whose target URL comes from an environment variable.
- Assert the endpoint scheme and host against a known value before sending credentials.
- Never attach secrets to a request whose destination is not verified.
- Lock down who can change the CI variables and config that feed the build.