Devsecops reference

From Crapule421/tiger-team · View interactive version

Devsecops reference is an AI agent skill from the GitHub repository Crapule421/tiger-team. DevSecOps knowledge base - secure CI/CD, IaC, containers and Kubernetes/OpenShift, secrets, SAST/DAST/SCA/SBOM, supply chain (SLSA), hardening (CIS, ANSSI), audit logging, release strategies and review checklist.

How to use this skill

Skill file

DevSecOps reference

Senior-level cheat sheet. Product details move fast: where a feature depends on edition or version it is flagged "verify against your version". Regulated contexts (banking/DORA, healthcare/HDS, defense/II 901) raise the bar on traceability, segregation of duties and evidence: every control below should produce an auditable trace.

1. Secure CI/CD - principles (all platforms)

| Principle | What it means in practice |

|---|---|

| Pipeline = production asset | Pipeline definitions, runners, shared templates and credentials get the same protection as prod servers. |

| Protected branches/tags | No direct push to main/release; merge via reviewed MR/PR; required status checks; no force push; tag protection for release tags. |

| Segregation of duties | Author cannot approve own change; deploy to prod requires approval by a distinct role; CODEOWNERS on pipeline files, IaC and security-sensitive paths. |

| Least-privilege runners | Ephemeral runners/agents, one job per VM/pod, no shared Docker socket, no privileged mode unless isolated, separate runner pools for prod deploys. |

| Short-lived credentials | OIDC federation to cloud/Vault instead of long-lived keys in CI variables; scope tokens to repo + branch + environment. |

| Untrusted input | MR/PR titles, branch names, commit messages, fork code are attacker-controlled: never interpolate them into shell; never run fork code with secrets. |

| Pin everything | Base images by digest, third-party actions/templates by commit SHA, tool versions explicit, dependency lock files committed. |

| Build once, promote | Same immutable artifact (by digest) promoted dev -> test -> prod; environment config injected at deploy time; never rebuild for prod. |

| Signed and traceable | Signed commits (GPG/SSH/X.509), signed artifacts/images, provenance attestation linking artifact -> commit -> pipeline run -> approver. |

| Fail closed | Security gates block on policy violations; exceptions are explicit, owned, time-boxed and recorded. |

Platform specifics

GitLab CI

Jenkins

Azure DevOps

GitHub Actions

OIDC federation to cloud / Vault

2. Signed commits and artifacts

3. Infrastructure as Code

Terraform / OpenTofu

| Topic | Rule |

|---|---|

| State | Remote backend with locking (S3-native lock file use_lockfile = true, Terraform 1.10+ - the DynamoDB lock table is deprecated; azurerm uses blob lease; GCS native locking). Never local state for shared infra. |

| State secrecy | State contains secrets in clear (DB passwords, keys). Encrypt the backend, restrict read access, enable versioning. sensitive = true only masks CLI output, not state. OpenTofu 1.7+ offers client-side state and plan encryption; Terraform 1.10+ offers ephemeral values/resources and 1.11+ write-only arguments (never persisted to plan or state). |

| Locking incidents | terraform force-unlock <LOCK_ID> only after confirming no run is active. |

| Versions | required_version and required_providers constraints; commit .terraform.lock.hcl. |

| Modules | Versioned (tag/registry version), pinned, small, documented inputs/outputs; no ref=main. |

| Plan/apply | terraform plan -out=tfplan reviewed, then terraform apply tfplan (same plan). Apply only from CI with a dedicated identity. |

| Drift | Scheduled terraform plan -detailed-exitcode (exit 0 no change, 1 error, 2 changes) or plan -refresh-only; alert on 2. Root cause the drift (manual change?) before re-applying. |

| Refactors | moved blocks / import blocks (recent versions) instead of manual state mv/import - reviewable in code. |

| Safety | lifecycle { prevent_destroy = true } on stateful resources; review every -/+ (replace) in plan; avoid routine -target. |

| Policy as code | Checkov, Trivy (config; tfsec merged into it), KICS, tflint; OPA/Conftest or Sentinel (HCP Terraform/Enterprise) on the plan JSON (terraform show -json tfplan). |

Ansible

4. Containers

Image hardening (Dockerfile)

Kubernetes

| Area | Controls |

|---|---|

| Pod securityContext | runAsNonRoot: true, allowPrivilegeEscalation: false, readOnlyRootFilesystem: true, capabilities: {drop: ["ALL"]}, seccompProfile: {type: RuntimeDefault}; no hostNetwork/hostPID/hostIPC/hostPath. |

| Pod Security Admission | PodSecurityPolicy was removed in 1.25. Label namespaces pod-security.kubernetes.io/enforce: restricted (also warn, audit); baseline minimum for exceptions. |

| Admission policy | Kyverno, OPA Gatekeeper or ValidatingAdmissionPolicy (CEL; GA in 1.30) for registry allowlist, signature verification, required labels, no latest. |

| RBAC | Namespaced Roles over ClusterRoles; no wildcard verbs/resources; avoid cluster-admin bindings. Dangerous: escalate, bind, impersonate, create pods (can run as any SA of the namespace), get/list secrets, nodes/proxy. Check with kubectl auth can-i --list --as=system:serviceaccount:<ns>:<sa>. |

| Service accounts | One SA per workload; automountServiceAccountToken: false unless the pod calls the API. |

| NetworkPolicies | Default deny ingress + egress per namespace, then explicit allows (including DNS egress to the cluster DNS). Requires a CNI that enforces them. |

| Secrets | Base64 is not encryption. Enable encryption at rest (EncryptionConfiguration, KMS provider). Prefer External Secrets Operator, Secrets Store CSI driver or Vault Agent injector; Sealed Secrets/SOPS for GitOps. Restrict get secrets RBAC. |

| Resources | Requests/limits, ResourceQuota/LimitRange per namespace (DoS containment). |

| Supply chain | Private registry, pull by digest, signature verification at admission, image pull secrets scoped. |

| Audit | API server audit policy: keep Secrets/ConfigMaps/TokenReviews at Metadata level (higher levels write secret values into the audit log); RequestResponse for RBAC changes if volume allows; ship to SIEM. |

| Benchmarks | CIS Kubernetes Benchmark (kube-bench), NSA/CISA Kubernetes Hardening Guide. |

OpenShift specifics

5. Secrets management

| Rule | Detail |

|---|---|

| Never in Git | Pre-commit + CI scanning (gitleaks, trufflehog, platform secret scanning). On leak: revoke/rotate first, then purge history; assume compromise. |

| Secret zero | Bootstrap via platform identity (K8s SA token, cloud IAM, CI OIDC), not a static token in a file. |

| Dynamic > static | Short TTL, per-consumer credentials, automatic revocation. |

| Rotation | Defined period, automated, tested; rotation must not need a release. |

| Audit | Every read of a secret logged and attributable. |

HashiCorp Vault (concepts): auth methods (AppRole, Kubernetes, JWT/OIDC, LDAP, TLS certificates, cloud IAM); secrets engines (KV v2 with versioning - API paths include data/, database dynamic credentials, PKI, Transit encryption-as-a-service, SSH); policies are deny-by-default (path "secret/data/app/*" { capabilities = ["read"] }); tokens and leases with TTL, renewal, revocation; seal/unseal (Shamir shares or auto-unseal via cloud KMS; PKCS#11/HSM auto-unseal and seal wrapping require Vault Enterprise); audit devices (Vault refuses requests if no enabled audit device can be written - enable at least two); namespaces and performance/DR replication are Enterprise features; response wrapping for secret delivery. OpenBao is the open-source fork.

CyberArk (concepts): Digital Vault with Safes (access-controlled containers); CPM (Central Policy Manager) rotates/verifies credentials on target systems; PVWA (web portal, request/approval workflows); PSM / PSM for SSH (isolated, recorded privileged sessions - the bastion for admin flows); application credentials via Credential Providers (agent-based or central CCP) and Conjur / Secrets Manager for DevOps workloads. Typical integration: pipeline or app retrieves credential at runtime by application identity; human admins connect only via PSM.

6. Security testing and SBOM

| Type | What | Where in pipeline | Example tools |

|---|---|---|---|

| Secrets scan | Hard-coded credentials | Pre-commit, every MR | gitleaks, trufflehog |

| SAST | Source code flaws | Every MR, incremental | Semgrep, SonarQube, CodeQL |

| SCA | Vulnerable/licensed dependencies | Every build + continuous re-scan of released SBOMs | OWASP Dependency-Check, Dependency-Track, Trivy, Grype, Snyk |

| IaC scan | Misconfiguration | Every MR | Checkov, Trivy config, KICS |

| Container scan | OS/package CVEs, misconfig | Build + registry re-scan | Trivy, Grype, Clair |

| DAST | Running app (auth, injection, headers, TLS) | Test env, nightly/pre-release | OWASP ZAP, Burp Suite |

| Pentest | Manual, business logic | Before go-live / major change | Qualified provider (PASSI in France) |

7. Supply chain security (SLSA)

8. Hardening baselines

| Baseline | Use |

|---|---|

| CIS Benchmarks | OS, Kubernetes, Docker, DBs, cloud. Level 1 (broadly applicable) / Level 2 (defense in depth). Assess with CIS-CAT, OpenSCAP, kube-bench. |

| ANSSI "Recommandations de configuration d'un systeme GNU/Linux" (BP-028) | French reference for Linux; v2.0 (October 2022) defines four cumulative levels: minimal, intermediary, enhanced, high. ComplianceAsCode/OpenSCAP ships anssi_bp28_minimal|intermediary|enhanced|high profiles aligned to v2.0 (RHEL 8/9 among others); list them with oscap info on your distro's datastream. |

| ANSSI secure administration guide (PA-022) | Admin tiering, dedicated admin workstations, bastions - basis for "admin flows via bastion". |

| ANSSI TLS guide (v1.2) and Docker fiche technique (FT-082, 2020) | TLS 1.3 preferred, TLS 1.2 accepted under conditions, SSLv3/TLS 1.0/1.1 forbidden; container isolation rules (dedicated namespaces, drop all capabilities, read-only root filesystem, resource limits). |

| Microsoft Security Baselines / CIS Windows | Windows Server, AD (see infra-reference windows.md). |

| Sector frameworks | Defense: II 901 (Diffusion Restreinte systems), IGI 1300 (classified); Healthcare: HDS certification; Cloud: SecNumCloud qualification. Confirm applicability with the security officer. |

Hardening rules: baseline as code (Ansible/OpenSCAP remediation), measured in CI and continuously (drift), deviations documented with risk acceptance, golden images rebuilt on a cadence rather than patched in place.

9. Observability and audit logging

| What to log | Detail |

|---|---|

| Identity | Logins, failures, MFA events, token issuance, privilege elevation (sudo, PSM sessions). |

| Change | Pipeline runs (who triggered, commit SHA, artifact digest, approver, target env), IaC applies, manual changes, config/feature-flag changes. |

| Secrets | Vault/CyberArk access logs, K8s secret reads, failed secret access. |

| Platform | K8s API audit, cloud control-plane logs, registry pushes/pulls, admission denials. |

| Security tools | Scan results and waivers (evidence for auditors). |

10. Release strategies

| Strategy | How | Pros | Watch-outs |

|---|---|---|---|

| Rolling | Replace instances progressively | Simple, no extra capacity | Mixed versions coexist; needs backward-compatible APIs/schema |

| Blue/green | Two full environments, switch traffic | Instant rollback (switch back) | Double capacity; DB is shared - schema must serve both; sessions/caches |

| Canary | Small % of traffic to new version, widen on healthy metrics | Limits blast radius | Needs good metrics/SLOs and automated analysis (Argo Rollouts, Flagger) |

| Feature flags | Code deployed dark, enabled per user/segment | Decouple deploy from release; kill switch | Flag debt; flag changes are prod changes (audit, approval); default-off; test both paths |

| Shadow/dark launch | Duplicate traffic to new version, discard responses | Real load without user impact | Side effects (writes, emails, payments) must be suppressed |

11. Review checklist

Pipeline

IaC

Containers / Kubernetes

Operations

Sources

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.