18 DevOps Security Practices Every Team Should Adopt
18 DevOps security practices grouped by identity, source, dependencies, pipeline and runtime: OIDC, secret scanning, SCA, SBOM, signing, SLSA, admission.
The DevOps security practices that matter most protect four things: the people and identities that can change code, the source and dependencies that go into a build, the pipeline that turns them into artifacts, and the runtime where those artifacts run. The 18 practices below are grouped that way, each with a concrete first step and an official reference.
Key takeaways
- Most pipeline breaches start with a stolen credential, so short-lived identity (SSO, MFA, OIDC for CI) comes first.
- Scanning is only useful when results block a merge or a deploy at an agreed severity.
- Signing and provenance let you prove where an artifact came from; an SBOM tells you what is inside it.
- Admission policy in Kubernetes stops insecure workloads before they start.
- Logging, patch targets and a rehearsed incident process close the loop.
- Adopt in order: identity, secrets, dependencies, pipeline, runtime. Do not try all 18 in one sprint.
This is a practical checklist inside our DevSecOps cluster. For the concepts behind it, start with how DevSecOps fits every stage of the lifecycle; for architecture, see 12 components of a DevSecOps architecture.
The 18 practices at a glance
| # | Practice | Area | Example tools |
|---|---|---|---|
| 1 | Threat model each service | Plan | OWASP Threat Dragon |
| 2 | SSO, MFA and least privilege | Identity | Your IdP, cloud IAM |
| 3 | Protected branches and required review | Source | GitHub, GitLab rules |
| 4 | Keep secrets out of code | Source | Vault, cloud secret managers |
| 5 | Secret scanning and push protection | Source | Gitleaks, platform scanners |
| 6 | Short-lived CI credentials via OIDC | Pipeline | GitHub Actions, GitLab OIDC |
| 7 | Pin and review dependencies | Dependencies | Lockfiles, Renovate, Dependabot |
| 8 | Software composition analysis | Dependencies | Trivy, OSV-Scanner |
| 9 | Static analysis (SAST) | Code | Semgrep, CodeQL |
| 10 | Infrastructure as code scanning | Code | Checkov, Trivy config |
| 11 | Minimal, scanned container images | Build | Distroless or slim bases, Trivy |
| 12 | Generate an SBOM per release | Build | Syft, CycloneDX, SPDX |
| 13 | Sign artifacts | Build | Sigstore cosign |
| 14 | Produce build provenance | Build | SLSA, platform attestations |
| 15 | Harden CI runners and workflows | Pipeline | Ephemeral runners, pinned actions |
| 16 | Admission policy in Kubernetes | Deploy | Pod Security Admission, Kyverno, OPA Gatekeeper |
| 17 | Runtime least privilege and segmentation | Runtime | NetworkPolicy, security groups |
| 18 | Logging, patch targets and incident response | Operate | Central logs, audit logs, runbooks |
Plan and identity
1. Threat model each service
A threat model is a short, structured conversation: what are we building, what can go wrong, what are we doing about it, and did we do a good job. Run one when a service is designed and again when its data flows change. Draw the data flow, mark trust boundaries (internet to load balancer, service to database, CI to cloud) and list the controls at each one. The output should be tickets, not a document nobody reads. Our post on continuous threat modeling covers making this routine.
2. Enforce SSO, MFA and least privilege
Every human account on Git hosting, CI, cloud consoles and registries should come from one identity provider with multi-factor authentication. Then trim permissions: developers rarely need production write access, and admin roles should be time-bound and logged. Remove accounts on the day someone leaves.
Source code
3. Protect branches and require review
Protect the default and release branches: no direct pushes, at least one approving review from someone other than the author, required status checks (tests and scanners) and no force pushes. Add a CODEOWNERS file so changes to pipeline definitions, infrastructure code and security settings need approval from the owning team. Pipeline files deserve the strictest review because whoever edits them controls what the build can reach.
4. Keep secrets out of code
Store passwords, tokens and keys in a secret manager such as HashiCorp Vault, AWS Secrets Manager, Azure Key Vault or Google Secret Manager, and inject them at runtime. Rotate them on a schedule and on any suspicion of exposure. Detailed patterns are in storing secrets safely around Git.
5. Turn on secret scanning and push protection
Scanning catches the mistakes that slip past rule 4. Run it in three places: a pre-commit hook on laptops, push protection on the Git server so known token formats are blocked before they land, and a scheduled scan of full history. When a secret is found, revoke and rotate it first; deleting the commit does not make it safe, because clones and caches may already hold it.
# scan the working tree and history of a repository
gitleaks git . --redact
Pipeline identity
6. Replace stored CI keys with OIDC federation
Long-lived cloud access keys saved as CI variables are a top target. GitHub Actions, GitLab CI and other platforms can issue an OpenID Connect token for each job, and AWS, Azure and Google Cloud can exchange it for short-lived credentials. Restrict the trust policy to a specific repository and branch or environment so a fork or feature branch cannot assume the production role.
permissions:
id-token: write
contents: read
steps:
- uses: aws-actions/configure-aws-credentials@v6
with:
role-to-assume: arn:aws:iam::111122223333:role/deploy-prod
aws-region: ap-south-1
Dependencies and code analysis
7. Pin and review dependencies
Commit lockfiles (package-lock.json, poetry.lock, go.sum) so builds use the exact versions you reviewed. Pin container base images by digest for production builds. Use an update bot to raise small, frequent upgrade pull requests that run through normal review, instead of rare large jumps that nobody can test properly. Prefer packages with active maintenance; the OpenSSF Scorecard gives an automated view of a project's security practices.
8. Run software composition analysis
SCA tools match your dependency tree against vulnerability databases such as OSV and the NVD. Agree on a gate: for example, block merges for critical and high issues that have a fix available, and track the rest with a due date. Unfixable issues need a written exception with an expiry so they get revisited.
9. Add static analysis to pull requests
SAST looks for risky patterns in your own code: SQL built from string concatenation, unsafe deserialisation, missing output encoding. Run it on every pull request and show findings inline so developers fix them while the code is fresh. Start with a small, high-confidence rule set; a scanner that floods the team with false positives gets ignored. The OWASP Top 10 is a sensible scope for first rules.
10. Scan infrastructure as code
Misconfiguration causes many cloud incidents: a public storage bucket, a security group open to the world, an unencrypted volume. Scan Terraform, CloudFormation, Helm charts and Kubernetes manifests in the same pull request that changes them.
trivy config ./infra
checkov -d ./infra
More examples are in preventing IaC misconfigurations.
Build and artifacts
11. Build minimal images and scan them
Fewer packages means fewer vulnerabilities to patch. Use multi-stage builds so compilers and build tools never reach the final image, start from a slim or distroless base, and run as a non-root user. Scan the image in CI and again in the registry on a schedule, because new CVEs are published against images that were clean on build day.
FROM golang:1.27 AS build
WORKDIR /src
COPY . .
RUN CGO_ENABLED=0 go build -o /app ./cmd/api
FROM gcr.io/distroless/static-debian13:nonroot
COPY --from=build /app /app
USER nonroot
ENTRYPOINT ["/app"]
12. Generate an SBOM for every release
A software bill of materials lists every component in an artifact in a standard format, SPDX or CycloneDX. Store it next to the artifact. When the next widely exploited library flaw is announced, you can search your SBOMs in minutes instead of grepping every repository. See how SBOMs support compliance and the guidance from CISA on SBOM.
syft registry.example.com/api:1.8.0 -o cyclonedx-json > sbom.json
13. Sign what you ship
Signing lets your deploy step verify that an image came from your pipeline and has not been swapped. Sigstore's cosign supports keyless signing, where the CI job's OIDC identity is bound to a short-lived certificate and recorded in a public transparency log, so there is no long-lived signing key to protect.
cosign sign registry.example.com/api@sha256:<digest>
cosign verify registry.example.com/api@sha256:<digest> \
--certificate-identity-regexp 'https://github.com/example-org/api/.*' \
--certificate-oidc-issuer https://token.actions.githubusercontent.com
14. Produce build provenance
Provenance is a signed statement of how an artifact was built: which source commit, which builder, which parameters. The SLSA framework (current specification v1.2) defines build levels that grow from simply producing provenance to producing it from a hardened, isolated build platform. Many CI platforms can generate SLSA-style attestations natively. Verify provenance at deploy time, not just at build time. Background reading: why artifact provenance matters.
15. Harden CI runners and workflows
- Use ephemeral runners that are destroyed after each job so nothing persists between builds.
- Pin third-party actions or templates to a full commit SHA, not a moving tag.
- Set default token permissions to read-only and grant write per job.
- Do not run privileged workflows on code from untrusted forks.
- Keep self-hosted runners for public repositories off your internal network.
The full list is in 15 security practices for CI/CD pipelines.
Deploy and runtime
16. Enforce admission policy in Kubernetes
Kubernetes ships Pod Security Admission with three standard levels: privileged, baseline and restricted. Label namespaces to enforce at least baseline, and restricted where workloads allow it. Add a policy engine such as Kyverno or OPA Gatekeeper for rules PSA does not cover: images only from your registry, signed images only, required resource limits.
kubectl label namespace payments \
pod-security.kubernetes.io/enforce=restricted \
pod-security.kubernetes.io/warn=restricted
17. Apply least privilege and segmentation at runtime
Give each workload its own service account and cloud role with only the permissions it needs. Default-deny network traffic and allow the specific flows a service uses, with Kubernetes NetworkPolicy or cloud security groups. Mount root filesystems read-only where possible and drop Linux capabilities. This is the zero trust idea applied to workloads: no traffic or permission is trusted by default.
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
name: default-deny
namespace: payments
spec:
podSelector: {}
policyTypes: ["Ingress", "Egress"]
18. Log centrally, set patch targets and rehearse incidents
Send application, Kubernetes audit, cloud audit (such as AWS CloudTrail) and CI logs to a central store that engineers cannot quietly edit, and alert on high-signal events: new admin users, disabled logging, secrets read at odd hours. Publish patch targets by severity so everyone knows how fast a critical fix must ship. Finally, write a short incident runbook (who decides, how to revoke credentials, how to roll back) and practise it twice a year.
A sensible adoption order
| Phase | Practices | Why first |
|---|---|---|
| Weeks 1 to 4 | 2, 3, 4, 5, 6 | Removes the easiest paths to a breach: weak logins and leaked keys |
| Months 2 to 3 | 7, 8, 10, 11, 15 | Cuts known vulnerabilities and pipeline exposure |
| Months 3 to 6 | 9, 12, 13, 16, 17 | Adds verification and runtime guardrails |
| Ongoing | 1, 14, 18 | Keeps the programme honest as systems change |
Measure progress with a few numbers you can actually collect: share of repositories with branch protection, share of pipelines using OIDC, open critical findings older than their target, and share of production images that are signed.
Common mistakes
- Scanners in warn-only mode forever. Pick a severity gate and enforce it, with a documented exception process.
- Security owned by one team. Platform teams should ship secure defaults (templates, base images, policies) so product teams get them for free.
- Deleting a leaked secret instead of rotating it. Rotation is the fix.
- Signing without verifying. A signature nobody checks at deploy time adds no protection.
- Ignoring the pipeline itself. CI systems hold the keys to production and need the same care as production.
Learn DevSecOps hands-on
Our DevSecOps training builds a pipeline with secret scanning, SCA, SAST, IaC scanning, SBOMs, signing and Kubernetes admission policy on real infrastructure. Classes run in Kharadi, Pune and live online across India.
Frequently asked questions
What is the first DevOps security practice a team should adopt?
Secure identity: single sign-on with MFA for every tool, least privilege roles and short-lived CI credentials through OIDC. Stolen or leaked credentials are the most common way into a pipeline.
What is the difference between SAST and SCA?
SAST analyses the code your team wrote for insecure patterns. SCA checks the third-party libraries you depend on against databases of known vulnerabilities.
Why should CI pipelines use OIDC instead of access keys?
OIDC lets each job exchange a short-lived identity token for temporary cloud credentials. There is no long-lived key stored in CI variables to leak, and trust can be limited to one repository and branch.
What is an SBOM used for?
An SBOM lists every component inside a release. When a new vulnerability is announced, you can find affected artifacts quickly and prove to auditors or customers what you ship.
What does signing a container image prove?
That the image was produced by an identity you trust, such as your CI workflow, and has not been altered. It only helps if deployments verify the signature before running the image.
What is SLSA?
Supply-chain Levels for Software Artifacts, an OpenSSF framework that defines levels of build integrity, centred on producing and verifying signed provenance. The current specification is v1.2.
Which Pod Security Standard should production namespaces use?
Enforce restricted wherever workloads can run without root or extra capabilities, and baseline as the minimum elsewhere. Avoid privileged except for trusted system components.
How do we stop leaked secrets from reaching Git?
Use a pre-commit scanner, enable push protection on your Git platform and scan history regularly. If a secret still leaks, revoke and rotate it immediately.
References
What's Your Reaction?
Like
0
Dislike
0
Love
0
Funny
0
Angry
0
Sad
0
Wow
0