A write-capable token turns successful code execution into persistence. If an attacker can push changes, approve merges, or trigger downstream jobs, one compromised workflow can alter the repository and extend access beyond the original execution point. That is why workflow permissions should be scoped separately for validation, release, and administrative actions.
How write-capable workflow tokens turn execution into repository control
A workflow token is not just a session marker for the current job when it can write back to the repository. It can change code, modify pipeline files, approve or influence merges, and create follow-on execution paths that outlive the original run. That is why a single compromised job can become a repository-level foothold rather than a one-time event.
The risk is highest when the token can touch files that define automation itself, because the workflow then becomes both the entry point and the persistence mechanism. A token with write access to source, workflow definitions, or release automation can turn ordinary build activity into a trusted change channel.
That is the same failure pattern seen when stolen tokens are used to push malicious commits or alter repository automation, as in Fake Dependabot commits 2023 and Sourcegraph breach 2023.
Why repository impact depends on the exact token scope
Not every write-capable token creates the same blast radius. A token that can only update a documentation branch is very different from one that can alter workflow files, tags, release branches, or protected merge paths. The security question is not simply “can it write?”, but “what trusted actions can it reach once code execution is already obtained?”
Repository compromise usually happens when scope is broader than the task needs. Validation jobs should not inherit release authority, and release automation should not be able to self-modify unless that is explicitly intended and tightly controlled. Separating those duties limits how far a compromised run can move.
Repository controls become especially important when write access is paired with secrets exposure, because a modified workflow can exfiltrate credentials on the next run or activate hidden steps only after review has passed. The repository then becomes a staging point for both persistence and lateral access.
For token lifecycle and secret handling, API Key Management Guide and Secrets Management Guide reinforce the practical distinction between temporary use and durable authority.
How attackers abuse workflow write paths for persistence and follow-on access
Once an attacker gets a write-capable workflow token, the immediate goal is often not loud destruction. It is to create durable control: add a malicious workflow, insert a dependency or action that phones home, change build logic to leak future tokens, or push a backdoor into a branch that downstream automation will trust.
Because repositories are often treated as a source of truth, malicious changes can propagate quickly into other systems. A compromised workflow can trigger deployment jobs, release processes, or package publication, turning one compromised execution into multiple trusted executions.
That is why repository compromise is often a supply-chain problem as much as an access problem. The attack succeeds when the organisation assumes the workflow is still acting on behalf of the repository owner after the token has been abused.
Current guidance on token-bound trust and delegation supports narrowing that assumption, including RFC 9700: Best Current Practice for OAuth 2.0 Security and RFC 8707: Resource Indicators for OAuth 2.0, which both push access toward tighter audience and token-use boundaries.
Risk and Threat Considerations
Write-capable workflow tokens create a high-value compromise path because they let an attacker convert short-lived execution access into durable repository control. The main exposure is not only code tampering, but the ability to plant persistence, alter automation trust paths, and pivot into downstream systems that consume repository changes.
Failure mechanism: A compromised workflow inherits write authority that can modify code, workflow definitions, or release automation, allowing the attacker to make the repository itself part of the persistence mechanism.
Impact: The attacker can extend access beyond the original job, inject malicious automation, and use trusted repository channels to reach build, deployment, or secret-handling systems.
Standards & Framework Alignment
This section maps relevant standards and security frameworks to the operational risks and controls described in this guidance.
OWASP Non-Human Identity Top 10 and OWASP API Security Top 10 address the attack and risk surface, while NIST SP 800-53 Rev 5 sets the governance and control requirements practitioners need to meet.
| Framework | Control / Reference | Relevance |
|---|---|---|
| OWASP Non-Human Identity Top 10 | NHI-05 — Overprivileged NHI | Write-capable workflow tokens create overprivileged non-human access paths. |
| NHI-01 — Improper Offboarding | Compromised or stale workflow tokens must be removed and rotated quickly. | |
| Recommendation — Scope workflow tokens to the minimum repository and branch actions required. Revoke and replace workflow tokens immediately after exposure or compromise. | ||
| NIST SP 800-53 Rev 5 | AC-6 — Least Privilege | Repository workflows need constrained write authority to limit compromise impact. |
| IA-5 — Authenticator Management | Workflow tokens are authenticators that need lifecycle control, rotation, and revocation. | |
| Recommendation — Limit each workflow token to the smallest set of repository actions it needs. Rotate, revoke, and inventory workflow tokens as managed authenticators. | ||
| OWASP API Security Top 10 | API5 — Broken Function Level Authorization | Tokens that can trigger privileged repository functions need function-level restriction. |
| Recommendation — Separate validation, release, and admin functions into distinct authorization paths. | ||
Practitioner Guidance
What to prioritise: Treat any workflow token that can write to source, workflows, or release paths as a higher-risk credential than a read-only execution token. The control decision should be based on what the token can change, not on whether the job is “internal”.
What to verify: Confirm that validation jobs cannot approve or publish their own outputs, that release workflows cannot edit the automation they depend on, and that protected branches or merge paths require a separate, explicitly governed authority. If one token can both run and rewrite the trusted path, the design is too permissive.
Practitioner takeaway: The key judgement is whether the token can influence the next trusted state, because once a workflow can rewrite what future automation trusts, compromise stops being a single event and becomes a repository-control problem.
Related resources from NHI Mgmt Group
- Why do signed repository tokens still create a compromise risk when scope enforcement is missing?
- Why do write-capable AI platform tokens create more risk than read-only tokens?
- Why do non-human identities create more risk than many human accounts?
- Why do non-human identities create more remediation risk than many human accounts?
Deepen Your Knowledge
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.
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