2026-11-29Gunner Technology

Keep Deployment Keys Out of Agent-Edited CI

Keep deployment secrets in a separate release service whose configuration and credentials coding agents cannot change or retrieve. Let ordinary CI build and check the work, then require the release service to verify approval for the exact artifact before deploying it. Protecting the main branch doesn't close a route that exposes your keys before a change ever gets merged.

Why isn't a protected main branch enough?

It controls what reaches that branch, but it doesn't establish which credentials an earlier job can use. CI, or continuous integration, runs automated builds and checks when code changes. If a proposed workflow can run with deployment credentials, the author of that workflow has a path to those credentials before release approval matters.
Dmitry Kudryavtsev describes this problem in Self-hosted software development factory. His setup gives coding agents isolated development machines and uses Forgejo for repositories and automated checks. He moved deployment keys out of Forgejo's secrets after recognizing that an agent could propose a workflow that exposed them, despite restrictions on merging and deploying from main.
The article describes his own system and the risks he identified. Its useful lesson is the route he traced: permission to edit a job can become permission to use whatever that job receives. Gunner Technology recommends examining that route directly instead of assuming branch protection covers it.

What belongs outside the agent's CI environment?

Keep deployment credentials and the machinery that decides when to use them outside the environment executing agent-edited jobs. In Kudryavtsev's system, Semaphore UI holds the deployment keys and runs a separate deployment script. That separation is more consequential than which products he chose.
Gunner's recommendation is to protect the release service's configuration separately from ordinary application edits. A coding agent should be able to submit work for checking without being able to replace the deployment script, grant a new release identity or change which destination receives the package. Moving a key to another server accomplishes little if an agent can tell that server to run an arbitrary command.
Give build jobs the access their checks require, and keep production authority out of them. Use a clean release environment rather than reusing a worker that just executed proposed code. Our guide to task-bound agent credentials explains the broader identity rule. Here, apply it to every process a workflow can start, including helpers.

How should checked work reach the release service?

Send a release request that identifies the approved work, and have the receiving service verify it independently. A webhook is an automated notification from another system; receiving one should start verification rather than grant permission to deploy whatever its message names. Check the sender, the repository, the successful checks and the recorded human approval.
An artifact is the built package you intend to deploy. Record its digest, a fingerprint of its contents, alongside the source commit and check results. The release service should retrieve that identified package from an approved location and compare it with the approval record. A mutable label such as the latest build cannot establish that connection. Our post on binding approval to a version covers why later edits invalidate earlier evidence.
Keep the request narrow: an approved artifact and destination, with permitted release options. Reject requests that supply their own deployment script or ask to export credentials. If required evidence is missing or the package differs, stop and ask the release owner to resolve it. A successful build alone cannot supply the missing authority.

How do you prove the separation holds?

Try to cross it in an isolated test environment using dummy credentials and a harmless deployment target. From the permissions available to a proposed CI change, attempt to read the dummy deployment secret, alter the release configuration and request an unapproved deployment. Check the receiving systems' records rather than relying on the agent's report.
Also submit a request for a different artifact and repeat a previously accepted request. The service should reject mismatches and handle repeats without blindly deploying again. Then run a valid, approved release through the same route. A boundary that blocks everything hasn't demonstrated that your factory can ship authorized work.
Retain these checks and run them when permissions, workflow triggers or release configuration change. Record which identity attempted each action and where it was refused. That gives the operator something concrete to investigate when a future change accidentally connects the build worker to the key vault.

What risk remains after the keys move?

Harmful application code can still pass through an inadequate review and reach production. Kudryavtsev explicitly acknowledges that limitation. Keeping agents away from deployment keys closes a credential route; it doesn't establish that the software they built behaves correctly or deserves production access.
Require independent checks of the application and keep its runtime permissions appropriate to its job. Don't execute package-supplied scripts in the environment holding deployment credentials. Keep a recoverable release record so the operator can identify what shipped and restore the previous version when needed. These controls address different failures, and each needs evidence.
Start with a release path in a repository you own. Find every place its jobs receive production authority, separate the release executor and demonstrate both refusal and successful approved delivery. People decide what gets built and whether the result is right. The factory should carry that decision into deployment without handing the builder the keys.
In response to Self-hosted software development factory by Kudmitry.

Quick answers

Does this require hosting the factory on our own hardware?

No. You can enforce the separation in your own cloud account, provided build workers cannot change or inherit the release service's authority.

Can an agent propose a deployment-script change?

Yes, through a separate review path. The proposal must not become the active release procedure merely because an ordinary application check passed.

What if a credential was already exposed in CI?

Revoke or rotate it and investigate its use. Moving the replacement key doesn't invalidate copies of the old credential.