Microsoft Azure Learning Journey

Shift Security Left Without Giving CI/CD Unlimited Access

Move security checks into the delivery path while keeping credentials, runners, and production permissions inside clear trust boundaries.

7 min read · 1267 words
Microsoft AzureCI/CDGitHub ActionsAzure DevOpsDevOps
Shift Security Left Without Giving CI/CD Unlimited Access cover image

A scanner can find a vulnerable dependency, but an over-privileged workflow can still publish it directly to production. DevSecOps is the practice of integrating security decisions into the software lifecycle—not a license to add every scanner or expose production credentials to every build.

What you’ll learn

Prerequisites

Threat-model the pipeline first

The build pipeline executes code from dependencies, build scripts, actions, and sometimes pull requests. A malicious dependency or untrusted change can read files and environment variables accessible to its job. A self-hosted agent can preserve data across runs. A valid OIDC token can become a short-lived cloud token if Azure trusts that job.

Start with the questions:

Put each check at the right boundary

Use a small set of checks with clear owners and actionable output. A scanner that blocks every build for untriaged low-risk findings will be bypassed. A scanner that reports without an owner will be ignored.

Hands-on: run no-deployment checks

No Azure resources are created. From the repository root, run only the checks relevant to files it contains:

# Node.js application with a committed lockfile
npm ci
npm audit --omit=dev --audit-level=high
npm test

# Terraform project
terraform fmt -check -recursive
terraform validate

# Bicep template, when the Bicep CLI is installed
az bicep lint --file main.bicep

Record which check failed, the affected component, severity, and disposition. Do not treat npm audit as a complete supply-chain review; it does not inspect every container layer, workflow action, secret, or Azure policy.

✅ Checkpoint: A pull-request workflow can run these checks with contents: read and no Azure login. A failure prevents promotion rather than printing a secret or deploying partial changes.

Workflow permissions and secret handling

Begin with minimum token permissions and add them to the smallest job that needs them:

permissions:
  contents: read

jobs:
  scan:
    permissions:
      contents: read

If a later deployment job needs OIDC, grant id-token: write to that job—not to every job or the whole workflow by default. This permission allows a token request; the external trust policy and cloud role remain separate controls.

Do not pass untrusted pull-request titles, branch names, issue text, or dispatch inputs into shell commands or credential-action inputs. Use environment variables and validate formats; avoid expression interpolation inside run scripts. Do not use pull_request_target to check out and execute untrusted code with privileged credentials. Masking is a log safeguard, not a safe place to store or transform secrets.

On Azure Pipelines, protect service connections and production environments with resource checks outside YAML. On GitHub, use protected environments and branch rules where the repository plan supports them. In either system, prevent untrusted builds from sharing a persistent runner with privileged deployment jobs.

SBOMs and provenance

An SBOM inventories components in a build. An attestation makes a signed claim about how an artifact was produced and by which workflow. They support investigation and policy decisions, but do not prove that dependencies are safe, that the source was reviewed, or that the deployed digest matches the attested artifact. Keep the image digest, source commit, scanner result, SBOM, and approval linked in release evidence.

Some GitHub security features and artifact attestations have plan or repository-visibility requirements. Verify current terms, retention behavior, and verification support. Do not make a deployment depend on a feature the organization is not licensed or configured to use.

Troubleshooting

Five-pillar readiness checklist

Cleanup

The exercise created no cloud resources. Remove temporary reports that contain proprietary source or dependency details according to the repository’s retention policy. Rotate any credentials a scan finds; deleting a report does not revoke a credential.

Key takeaways

Next: One push to Azure: full delivery pipeline lab.

Series navigation: Previous: Azure Pipelines · Current: Phase 7, Part 4 · Next: Full pipeline lab

References

Share this article

LinkedIn post draft