A publish block trusts an environment variable for its destination. The auth block right below it fires for any host that variable names.
What goes wrong
Look at the publish block and the credentials sit a few lines under the destination. The destination is an environment variable, used raw. The credentials are unconditional. Nothing checks that the two belong together, so the secret authenticates to whatever the variable resolved to.
That gap is the whole bug. Point the variable at an attacker-run server and the release step logs in to it, sending the username and secret across. It reads as a normal publish in the logs, because from the build's point of view it is one. The only thing that changed was an address nobody validated.
Rated high because the payoff is publishing credentials, which are often reusable and let an attacker push tampered artifacts under your name. The prerequisite, influence over a build variable, is met more often than teams like to admit.
The pattern
repository {
url = System.getenv('REPO_URL') // trusted blindly
credentials {
username = System.getenv('REPO_USER')
password = System.getenv('REPO_SECRET')
}
}def repo = System.getenv('REPO_URL')
require(repo == EXPECTED_REPO_URL) { 'unexpected publish target' }
repository {
url = repo
credentials {
username = System.getenv('REPO_USER')
password = System.getenv('REPO_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
A credentialed request to an unvalidated destination is credential exfiltration waiting for a trigger. This keeps happening because the destination and the auth are written as separate concerns, so nobody asks whether the secret should follow the URL wherever it goes. Bind the two. If the target is not the registry you expect, do not send the secret.
Check your own code
- Check that every credentialed publish target is pinned to an exact expected URL.
- Reject builds where the registry host does not match the one your secrets belong to.
- Keep publishing secrets out of environments that run untrusted PR code.
- Rotate any publishing credential that could have reached an unverified host.