/devsecops-skills:checkov-and-tfsec-iac-security-scanningfrom devsecops-skills
Configures Checkov and tfsec to scan Terraform/CloudFormation/Kubernetes IaC for misconfigurations: hardcoded secrets, overly permissive IAM, unencrypted storage, open security groups, before deployment.
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.
Infrastructure-as-code misconfigurations are a distinct risk category from
both application-level vulnerabilities (SAST/DAST) and vulnerable
dependencies (SCA): a syntactically valid, perfectly-passing-terraform plan Terraform module can still define an S3 bucket with public read
access, a security group open to 0.0.0.0/0 on all ports, an IAM policy
granting *:*, or an unencrypted RDS instance — none of which Terraform
itself will refuse to apply, and none of which a dependency scanner or a
code-quality linter is positioned to catch. Checkov and tfsec are
purpose-built, static-analysis scanners for exactly this: they parse
Terraform (and, for Checkov, CloudFormation, Kubernetes manifests, ARM/Bicep,
Serverless Framework, and Dockerfiles) before any resource is provisioned,
and check it against a large ruleset of cloud-security best practices. This
is a narrower, IaC-specific scope than Snyk's multi-product platform
(snyk iac test covers similar ground as one of three Snyk scan types
alongside dependency and container scanning — see
snyk-vulnerability-and-license-scanning)
and a different concern entirely from generic dependency scanning (see
software-composition-analysis-sca):
Checkov/tfsec don't care what packages your application depends on, only
whether the infrastructure you're about to create is configured safely.
Both tools are free and open-source, which makes them a common choice when
a team wants dedicated IaC scanning without adopting a commercial platform's
full per-seat licensing for that purpose alone.
terraform apply (or pre-CloudFormation-deploy) security
gate that catches misconfigurations — hardcoded secrets in .tf files,
overly permissive IAM, open security groups, unencrypted storage/volumes
— as a PR check, before any cloud resource is actually created..checkov.yaml config or a tfsec
.tfsec/config.yml, including custom checks and suppressions..tf/.tfvars, CloudFormation
YAML/JSON templates, Kubernetes manifests, or Helm charts) — neither tool
needs a live cloud connection or a deployed environment; both scan source
statically.pip install checkov or the container image
bridgecrew/checkov) — Python-based, broadest format coverage
(Terraform, CloudFormation, Kubernetes, Helm, ARM/Bicep, Serverless
Framework, Dockerfile, and plain YAML/JSON for some checks).brew install tfsec /
container image) — Terraform-only, narrower format scope but often
faster on large Terraform-only repos; note that tfsec's checks have been
progressively merged into Trivy's IaC scanning (trivy config) by
its maintainer (Aqua Security) — confirm which binary/command your
pipeline actually invokes and whether you're intentionally on tfsec
standalone or Trivy's merged IaC scanner, since both currently exist and
behavior can differ by version.Run a baseline scan to see current exposure before gating anything, on both tools if evaluating them side by side:
checkov -d infra/terraform --compact
tfsec infra/terraform
Add Checkov to CI as a PR-blocking step, scoping the directory and failing on the framework(s) actually in use:
name: iac-security-scan
on: [pull_request]
jobs:
checkov:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Run Checkov
uses: bridgecrewio/checkov-action@v12
with:
directory: infra/terraform
framework: terraform
output_format: cli,sarif
output_file_path: console,checkov-results.sarif
soft_fail: false
- name: Upload SARIF to code scanning
if: always()
uses: github/codeql-action/upload-sarif@v3
with:
sarif_file: checkov-results.sarif
Uploading SARIF surfaces findings directly in GitHub's code-scanning UI as annotations on the PR diff, not just a pass/fail job status.
Add tfsec (or Trivy's merged IaC scanner) as an equivalent, faster Terraform-only pass if the repo is Terraform-only and scan speed on a large module tree matters:
jobs:
tfsec:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: aquasecurity/[email protected]
with:
working_directory: infra/terraform
sarif_file: tfsec-results.sarif
Running both Checkov and tfsec is reasonable during an evaluation period or for defense-in-depth on Terraform specifically (differing rule authors sometimes catch different things), but pick one as the actual blocking gate long-term — two blocking scanners with no severity-reconciliation rule produces the same "which gate do we trust" confusion described in snyk-vulnerability-and-license-scanning.
Suppress a specific finding with justification and an ID-scoped inline comment, never a directory-wide skip, in Checkov:
resource "aws_s3_bucket" "static_assets" {
bucket = "example-public-static-assets"
# checkov:skip=CKV_AWS_20:Bucket intentionally public — serves static
# website assets only, no sensitive data. Reviewed 2026-07-01, JIRA-5102.
}
tfsec equivalent, via an inline #tfsec:ignore comment:
resource "aws_security_group_rule" "public_health_check" {
type = "ingress"
from_port = 80
to_port = 80
protocol = "tcp"
cidr_blocks = ["0.0.0.0/0"]
security_group_id = aws_security_group.lb.id
#tfsec:ignore:aws-vpc-no-public-ingress-sgr -- ALB health check endpoint, intentionally public on port 80 only
}
Warning: never suppress a hardcoded-secret finding (an API key, password, or access key literal detected in
.tf/.tfvars) with acheckov:skip/#tfsec:ignorecomment. A suppressed secret finding does not make the secret safe — it only silences the scanner while the credential remains exposed in source control history. Rotate the credential and move it to a secrets manager or masked CI variable instead; see the pitfall below for the concrete fix.
Configure a persistent suppression list for findings that apply broadly (e.g. a specific check that's a known false positive for your module conventions), rather than repeating inline comments everywhere:
# .checkov.yaml
skip-check:
- CKV_AWS_8 # example: instance-level detail covered instead at the AMI level
compact: true
framework:
- terraform
soft-fail-on:
- LOW
Fail the build only on real findings for the resources you actually
control. Both tools flag data-source blocks or third-party module
internals sometimes; scope scans to your own module directories rather
than vendored/third-party module caches (.terraform/modules/**) where
findings aren't actionable by your team.
Run the scan before terraform plan/apply in the pipeline sequence
— this is the entire point of static IaC scanning: catching the
misconfiguration at PR time, before any resource exists, rather than
discovering it via a runtime scan or an incident after the resource is
already live. Place it as an early, fast-failing stage per the general
staging guidance in
ci-cd-pipeline-design.
Re-scan on a schedule, not only on .tf file changes — both tools'
rulesets are updated over time as new best-practice checks are added;
a module that passed six months ago may fail against a newer ruleset
version even with no code change, similar in spirit to how a dependency
scan can newly fail with no code change per
software-composition-analysis-sca.
checkov:skip=,
#tfsec:ignore) over a global rule disable in config — a globally
disabled check silently stops protecting every future resource, not just
the one it was meant to exempt.bridgecrewio/checkov-action@v12, a
specific tfsec/Trivy release) rather than floating on latest — both
tools' rulesets evolve, and an unpinned version can newly fail a
previously-clean pipeline with no code change, which should be treated as
expected ruleset drift, not a broken pipeline, but only if you're aware
it's happening.iac-security-scan,
not lumped into a generic lint job) so a failure is immediately
traceable to a security finding, not confused with a formatting or
syntax error from terraform validate.Symptom: Checkov or tfsec flags a hardcoded value that looks like a
secret (an API key, a password) directly in a .tf/.tfvars file.
Fix: Do not suppress this finding — move the value out of source
entirely into a secrets manager or CI masked variable
(TF_VAR_db_password injected at apply time, sensitive = true on the
corresponding variable) per the secrets guidance in
infrastructure-as-code-terraform;
a hardcoded secret finding is a real, urgent risk, not a false positive
to work around.
Symptom: A newly-added scan surfaces hundreds of pre-existing
findings across an established IaC codebase on day one, and the team is
tempted to disable the check or skip scanning entirely rather than face
the backlog.
Fix: Set soft-fail/non-blocking mode initially to establish a
baseline without blocking merges, triage the backlog by severity with an
owner and SLA per finding class, and only flip the gate to hard-blocking
once the existing backlog is under active remediation — the same phased
rollout pattern used when any new blocking scanner is introduced to a
previously-unscanned codebase.
Symptom: A finding is flagged on a data source block or a third-party
module's internal resource that the team doesn't directly author or
control.
Fix: Scope the scan's target directory to exclude third-party module
caches (.terraform/modules/**) and vendored code; a finding you can't
act on directly just adds noise to the actionable backlog.
Symptom: tfsec and Checkov report different severities (or one flags something the other doesn't) for what looks like the same underlying misconfiguration. Fix: This is expected — the two tools maintain independently authored rulesets. Pick one as the primary blocking gate (or explicitly run both as complementary, reconciling differences manually) rather than treating disagreement as a bug in either tool; the same reconciliation principle applies across any pair of security scanners per snyk-vulnerability-and-license-scanning.
Symptom: A previously-passing pipeline starts failing a Checkov/tfsec scan after a routine scanner version bump, with no infrastructure change. Fix: Confirm this is a ruleset update (new checks added in the newer scanner version) rather than a regression — review the new failing check's rationale, remediate or suppress with justification as appropriate, and consider pinning the scanner version deliberately going forward if unannounced ruleset changes shouldn't surprise the pipeline.
Scenario: A team adds Checkov to CI for a Terraform module tree that provisions an S3 bucket and a security group, catching an open ingress rule and an unencrypted bucket before merge.
infra/terraform/main.tf (before fix):
resource "aws_s3_bucket" "app_data" {
bucket = "example-app-data"
}
resource "aws_security_group" "app" {
name = "app-sg"
ingress {
from_port = 22
to_port = 22
protocol = "tcp"
cidr_blocks = ["0.0.0.0/0"]
}
}
Checkov CI run:
Check: CKV_AWS_19 "Ensure all data stored in the S3 bucket is securely encrypted at rest"
FAILED for resource: aws_s3_bucket.app_data
File: infra/terraform/main.tf:1-3
Check: CKV_AWS_24 "Ensure no security groups allow ingress from 0.0.0.0:0 to port 22"
FAILED for resource: aws_security_group.app
File: infra/terraform/main.tf:5-14
Fix applied:
resource "aws_s3_bucket" "app_data" {
bucket = "example-app-data"
}
resource "aws_s3_bucket_server_side_encryption_configuration" "app_data" {
bucket = aws_s3_bucket.app_data.id
rule {
apply_server_side_encryption_by_default {
sse_algorithm = "AES256"
}
}
}
resource "aws_security_group" "app" {
name = "app-sg"
ingress {
from_port = 22
to_port = 22
protocol = "tcp"
cidr_blocks = ["10.0.0.0/8"] # restricted to internal VPN/office CIDR, not the open internet
}
}
Re-running checkov -d infra/terraform --compact shows both checks passing,
and the PR merges with the misconfiguration caught before terraform apply
ever ran against a real AWS account — no bucket was ever briefly public and
no security group was ever briefly open, because the scan ran on source
before provisioning.
What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
npx claudepluginhub selvarajmurugesan90/ops-engineering-skills --plugin devsecops-skills17 skills in this plugin
/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.
/dast-integrationGuides adding Dynamic Application Security Testing (DAST) — automated black-box scanning of a running web application or API — using tools such as OWASP ZAP or Nuclei, in CI/CD or on a scheduled cadence against a staging environment. Use when the user asks to "add DAST scanning", "run a ZAP baseline scan against staging", "automate OWASP scanning in the pipeline", "test the running app for injection/auth/config vulnerabilities", or "scan our API for security issues before release". Complements, but does not replace, SAST or SCA static analysis.
Other plugins' skills for the same job