/devsecops-skills:secrets-managementfrom devsecops-skills
Guides eliminating hardcoded secrets, setting up secrets managers (HashiCorp Vault, AWS Secrets Manager, Azure Key Vault), rotating credentials, and adding secret-scanning to catch leaks.
Ships in devsecops-skills. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
Hardcoded credentials — API keys, database passwords, TLS private keys, cloud IAM keys — committed to source control or baked into CI/CD configuration are one of the most common and most consequential security failures, because a leaked secret is immediately and directly exploitable (no reverse-engineering or chained exploit required), and git history makes "delete the file" an incomplete fix. This skill covers three related problems: preventing secrets from entering source control and CI logs in the first place (scanning, pre-commit hooks), storing and distributing secrets correctly at runtime (a dedicated secrets manager rather than environment variables baked into images or config files), and responding when a secret does leak (rotation, revocation, blast-radius assessment).
Add secret-scanning first, before anything else, so you stop the bleeding while you build out proper management:
# GitHub Actions - Gitleaks
name: secret-scan
on: [push, pull_request]
jobs:
gitleaks:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: gitleaks/gitleaks-action@v2
env:
GITLEAKS_LICENSE: ${{ secrets.GITLEAKS_LICENSE }}
Add a matching pre-commit hook so leaks are caught before they're even pushed:
# .pre-commit-config.yaml
repos:
- repo: https://github.com/gitleaks/gitleaks
rev: v8.18.4
hooks:
- id: gitleaks
Inventory existing hardcoded secrets found by the scan, and for each one: rotate/revoke it at the source system first (assume it's compromised the moment it was committed, even to a private repo — git history persists), then remove it from code, and only then consider the finding resolved. Removing the file without rotating the credential leaves the leaked value valid forever in history.
Stand up the secrets manager. Vault example — enable a KV v2 secrets engine and a policy scoped to least privilege:
vault secrets enable -path=myapp kv-v2
vault kv put myapp/prod/db username="svc-myapp" password="<generated>"
# policy: myapp-prod-read.hcl
path "myapp/data/prod/*" {
capabilities = ["read"]
}
Authenticate workloads, not humans, to fetch secrets at runtime. Kubernetes example using Vault's Kubernetes auth method with the Vault Agent Injector (annotations on a pod spec):
metadata:
annotations:
vault.hashicorp.com/agent-inject: "true"
vault.hashicorp.com/role: "myapp-prod"
vault.hashicorp.com/agent-inject-secret-db-creds: "myapp/data/prod/db"
This avoids ever writing the secret into a Kubernetes Secret object, environment variable dump, or CI log — the sidecar fetches it directly into a file the app reads at startup.
For GitOps, encrypt secrets at rest with SOPS rather than committing plaintext or relying on cluster RBAC alone:
# .sops.yaml
creation_rules:
- path_regex: secrets/.*\.yaml$
kms: arn:aws:kms:us-east-1:<AWS_ACCOUNT_ID>:key/<KMS_KEY_ID>
sops --encrypt --in-place secrets/prod-db.yaml
git add secrets/prod-db.yaml # ciphertext only — safe to commit
Prefer dynamic, short-lived secrets over long-lived static ones where the backing system supports it (Vault's database secrets engine generates a unique DB credential per lease with automatic expiry, versus a single shared password rotated manually every 90 days).
Set a rotation policy and automate it for anything that must remain static (API keys for third-party SaaS without dynamic-secret support): document an owner, a rotation interval, and an automated or scripted rotation procedure — not a calendar reminder to do it manually.
Mask secrets in CI logs explicitly even when using a secrets manager — a script that echoes a fetched secret for debugging, or a stack trace that includes a connection string, leaks it just as badly as a hardcoded value.
git filter-repo / BFG), and even that doesn't help
once it's been cloned or indexed.ps aux), and (for Docker build args)
potentially cached image layers. Use environment variables sourced from
a secrets manager, files mounted at runtime, or BuildKit secret mounts
(--mount=type=secret) instead.Symptom: A secret was committed, the commit was reverted/force-pushed away, and the team considers the incident closed. Fix: Treat the credential as permanently compromised regardless of history rewriting — rotate/revoke it at the source system. History rewriting only helps prevent future discovery; it does not undo exposure to anyone who already cloned, forked, or indexed the repo (including any CI system or bot that pulled it in the interim).
Symptom: Secrets are stored in a secrets manager, but a debug log statement or an unhandled exception prints the full config object, leaking the secret into application logs anyway. Fix: Redact known secret fields in logging middleware/formatters at the framework level (structured logging with an explicit denylist of field names) rather than relying on developers to remember not to log the config object.
Symptom: A Docker image built with --build-arg DB_PASSWORD=...
works fine, but the password is later found inside an intermediate
layer via docker history even after the final stage doesn't reference
it.
Fix: Use BuildKit secret mounts (RUN --mount=type=secret,id=dbpass)
which never persist the value in any image layer, instead of build
args, for any credential needed only during the build.
Symptom: Vault (or another secrets manager) is deployed, but every service shares one broad "read everything" policy/token because writing per-service policies felt slow. Fix: Invest in per-service/per-environment policies up front — retrofitting least privilege after a broad token is already distributed to a dozen services is far more disruptive than doing it at rollout time.
Symptom: A rotated database password breaks the application because it was cached in a connection pool or a long-lived environment variable that isn't reloaded until restart. Fix: Design rotation to be observed by the app at runtime (short connection pool max-lifetime, a sidecar that re-renders config and signals a reload, or dynamic secrets with lease renewal) rather than assuming rotation alone is sufficient without an app-side refresh path.
A team finds a hardcoded AWS access key in config/settings.py via a
newly-added Gitleaks scan, and migrates the service to Vault-issued
dynamic AWS credentials.
Gitleaks finding:
Finding: <AWS_ACCESS_KEY_ID>
Secret: <REDACTED_EXAMPLE_NOT_A_REAL_KEY>
RuleID: aws-access-token
File: config/settings.py
Line: 14
Commit: 3f9a21c
Response, in order:
aws iam update-access-key --access-key-id <KEY_ID> --status Inactive),
then delete it once confirmed unused.config/settings.py and replace with a
Vault-issued dynamic credential:
vault secrets enable -path=aws aws
vault write aws/roles/myapp-prod \
credential_type=iam_user \
[email protected]
# settings.py — fetch a short-lived credential at startup instead of
# embedding one
import hvac
client = hvac.Client(url=os.environ["VAULT_ADDR"])
creds = client.secrets.aws.generate_credentials(name="myapp-prod")
git filter-repo --path config/settings.py --invert-paths or a
targeted BFG run) as defense-in-depth — understanding this does not
undo the exposure, only limits future discovery.What SKILL.md sets; muted values are Claude Code's defaults
npx claudepluginhub selvarajmurugesan90/ops-engineering-skills --plugin devsecops-skills17 skills in this plugin
/checkov-and-tfsec-iac-security-scanningConfigures Checkov and tfsec to scan Terraform/CloudFormation/Kubernetes IaC source for misconfigurations — hardcoded secrets, overly permissive IAM policies, unencrypted storage, open security groups — before `terraform apply` or `aws cloudformation deploy` ever runs. Use when a user asks to "scan my Terraform for security issues," "add Checkov/tfsec to CI," "find overly permissive IAM in my IaC," "write a Checkov suppression," "compare Checkov and tfsec," or "catch misconfigured cloud resources before they're provisioned."
/complete-devsecops-pipeline-for-kubernetes-from-scratchBuilds the complete security-gate sequence for a Kubernetes-targeted DevSecOps pipeline from scratch — SAST, SCA, container image scanning, a policy-as-code (OPA/Kyverno) admission gate placed before the GitOps handoff, and a secrets model where plaintext credentials never touch the pipeline because an External Secrets Operator pulls them cluster-side instead. Use when the user asks to "build a DevSecOps pipeline for Kubernetes from scratch," "add a policy gate before our GitOps commit," "make sure secrets never touch CI for our K8s deploys," or "sequence SAST/SCA/image-scan/policy gates for a container pipeline end-to-end."
/complete-devsecops-pipeline-for-serverless-from-scratchBuilds the complete security-gate sequence for a serverless (Lambda- style) DevSecOps pipeline from scratch — SAST, SCA against a much larger bundled transitive-dependency surface, package/artifact signing, and least-privilege execution-role scoping as the primary release gate (rather than a Kubernetes-style admission policy), with runtime secrets fetched from a managed secrets service instead of baked into the deployment package. Use when the user asks to "build a DevSecOps pipeline for a Lambda function from scratch," "gate a serverless release on execution-role scope instead of admission policy," "sign a Lambda deployment package," or "make sure a Lambda function's secrets aren't baked into its zip."
/complete-devsecops-pipeline-for-vm-based-workloads-from-scratchBuilds the complete security-gate sequence for a VM-based DevSecOps pipeline from scratch — SAST, SCA, golden-image scanning and CIS benchmark hardening baked into the machine image itself, config- management-applied secrets via Ansible Vault (never plaintext), and an ongoing patch/drift-detection gate that runs independently of any single deploy, distinct from the per-deploy scanning in the Kubernetes and serverless variants. Use when the user asks to "build a DevSecOps pipeline for EC2/VM workloads from scratch," "harden a golden AMI to CIS benchmarks in the pipeline," "apply secrets with Ansible Vault instead of plaintext," or "add ongoing patch/drift detection for a VM fleet."
/container-image-hardeningGuides building minimal, non-root, hardened container images — multi-stage builds, distroless/minimal base images, non-root users, read-only root filesystems, dropped Linux capabilities, and pinned/ digest-referenced base images. Use when the user asks to "harden this Dockerfile", "reduce container image attack surface/size", "make our container run as non-root", "switch to a distroless base image", "fix a container security scan finding about running as root or having a shell", or "set Kubernetes securityContext restrictions for a pod".
/critical-vulnerability-emergency-responseGuides the accelerated, out-of-band response when a critical CVE is publicly disclosed in a widely-used dependency, library, or platform component — rapid exposure assessment across the fleet, patch or temporary mitigation, verification, and closeout. Use when the user says "a critical CVE just dropped in X", "we need to check if we're affected by CVE-YYYY-NNNNN", "log4shell-style emergency patching", "zero-day just disclosed in our dependency", or "run an emergency vulnerability response". Distinct from the steady-state finding-queue management in security-finding-backlog-triage — this is the fire-drill process for one urgent, time-critical disclosure.
Other plugins' skills for the same job