Infrastructure-as-code has become the standard for provisioning cloud resources, kubernetes clusters, and container deployments. But with every Terraform module, Helm chart, and dockerfile committed to version control comes a critical question: is your infrastructure configuration actually secure?
Cloud misconfigurations are the leading cause of data breaches in modern deployments. An exposed S3 bucket, an overly permissive IAM role, or a Kubernetes pod running as root can compromise your entire environment. Self-hosted IaC scanning tools catch these issues before you apply changes — no cloud API keys required, no data sent to third-party services.
This guide compares three open-source IaC security scanners — Checkov, tfsec, and Trivy — evaluating their coverage, accuracy, deployment options, and CI/CD integration so you can choose the right tool for your pipeline.
For related reading, see our OpenTofu vs Terraform vs Pulumi guide for infrastructure-as-code platform comparisons, and our Trivy vulnerability scanner guide for a broader look at Trivy’s capabilities beyond IaC.
Why Self-Host Infrastructure-as-Code Scanning
Running IaC security scanners on your own infrastructure offers several advantages over SaaS alternatives:
- Full code privacy: Your Terraform files, Kubernetes manifests, and CloudFormation templates never leave your network. For regulated industries (finance, healthcare, government), this is often a compliance requirement.
- No API rate limits: Cloud-based scanners may throttle scans or require API tokens. Self-hosted tools run locally with no external dependencies.
- Faster feedback loops: Local scanning completes in seconds, providing immediate feedback during development rather than waiting for a remote service to respond.
- Custom policies: You can write and test custom security policies that reflect your organization’s specific requirements without waiting for a vendor to add support.
- Offline operation: Air-gapped environments (common in defense, critical infrastructure, and some enterprise setups) require tools that work without internet connectivity.
All three tools covered in this guide — Checkov, tfsec, and Trivy — are fully self-hostable, open-source, and support scanning without sending any data to external services.
Checkov: Comprehensive Cloud-Native Policy Engine
Checkov by Bridgecrew (now part of Palo Alto Networks) is a policy-as-code framework that scans infrastructure-as-code files for security misconfigurations. It supports the broadest range of IaC formats among the three tools.
| Attribute | Details |
|---|---|
| Repository | bridgecrewio/checkov |
| Stars | 8,645+ |
| Last Updated | April 2026 |
| License | Apache 2.0 |
| Language | Python |
| Best For | Multi-cloud policy enforcement with custom rule writing |
Supported Scanners
Checkov includes dedicated scanners for:
- Terraform (AWS, Azure, GCP, Oracle Cloud, GitHub, Kubernetes)
- CloudFormation (AWS)
- Kubernetes (YAML, Helm, Kustomize)
- Dockerfile
- ARM Templates (Azure)
- Serverless Framework
- OpenAPI/Swagger
- Bicep (Azure)
- Terraform Plan JSON
Policy Framework
Checkov’s policy engine uses Python classes or YAML definitions. Each policy includes:
- A unique ID (e.g.,
CKV_AWS_20) - Severity level (CRITICAL, HIGH, MEDIUM, LOW)
- Supported resource types
- The actual evaluation logic
You can write custom policies that check for organization-specific requirements:
| |
tfsec: Fast Terraform-Focused Scanner
tfsec was a dedicated Terraform static analysis tool known for its speed and simplicity. In 2023, the tfsec project was merged into Trivy, and the standalone tfsec repository is now in maintenance mode. The tfsec scanning engine lives on inside Trivy’s trivy config command.
| Attribute | Details |
|---|---|
| Repository | aquasecurity/tfsec |
| Stars | 6,986+ |
| Status | Merged into Trivy (maintenance mode) |
| License | MIT |
| Language | Go |
| Best For | Teams already using Trivy who need Terraform scanning |
Supported Scanners
tfsec focuses exclusively on Terraform, with support for:
- AWS provider (most extensive coverage)
- Azure provider
- GCP provider
- DigitalOcean provider
- OpenStack provider
- GitHub provider
- Kubernetes provider
- Oracle Cloud provider
- CloudStack provider
- Nutanix provider
Why tfsec Merged into Trivy
The merger makes strategic sense: Aqua Security’s Trivy already handled container image scanning and SBOM generation. Adding Terraform scanning created a unified security tool that covers the entire software supply chain — from code to container to cloud infrastructure.
For existing tfsec users, the migration is straightforward. The tfsec CLI flags map directly to trivy config flags, and the underlying Rego-based policies are largely compatible.
Trivy: Universal Security Scanner
Trivy by Aqua Security is a comprehensive vulnerability and misconfiguration scanner. While it started as a container image scanner, it now covers IaC files, SBOM generation, Kubernetes clusters, and Git repositories.
| Attribute | Details |
|---|---|
| Repository | aquasecurity/trivy |
| Stars | 34,596+ |
| Last Updated | April 2026 |
| License | Apache 2.0 |
| Language | Go |
| Best For | Teams wanting a single scanner for containers + IaC + SBOM |
Supported Scanners
Trivy’s trivy config subcommand handles:
- Terraform (including tfsec-compatible checks)
- CloudFormation
- Kubernetes (YAML, Helm, Kustomize, Dockerfile)
- Dockerfile
- Helm Charts
- Terraform Plan JSON
- Azure ARM Templates
- Ansible
- RedHat Openshift
Additionally, Trivy scans:
- Container images (OS packages, application dependencies)
- Filesystems and root filesystems
- Git repositories
- Virtual machine images
- Kubernetes clusters (live)
- SBOM generation and validation
Custom Policies
Trivy uses Rego (Open Policy Agent’s query language) for custom policies, making it compatible with OPA/Gatekeeper deployments:
| |
Feature Comparison
| Feature | Checkov | tfsec | Trivy |
|---|---|---|---|
| Terraform scanning | ✅ Yes | ✅ Yes (native) | ✅ Yes (via tfsec engine) |
| CloudFormation | ✅ Yes | ❌ No | ✅ Yes |
| Kubernetes YAML | ✅ Yes | ❌ No | ✅ Yes |
| Dockerfile | ✅ Yes | ❌ No | ✅ Yes |
| Helm charts | ✅ Yes | ❌ No | ✅ Yes |
| ARM Templates | ✅ Yes | ❌ No | ✅ Yes |
| Serverless Framework | ✅ Yes | ❌ No | ❌ No |
| Ansible | ❌ No | ❌ No | ✅ Yes |
| Bicep | ✅ Yes | ❌ No | ✅ Yes |
| OpenAPI | ✅ Yes | ❌ No | ❌ No |
| Container images | ❌ No | ❌ No | ✅ Yes |
| SBOM generation | ❌ No | ❌ No | ✅ Yes |
| Custom policies | Python, YAML | Rego | Rego |
| Suppression comments | ✅ Yes | ✅ Yes | ✅ Yes |
| SARIF output | ✅ Yes | ✅ Yes | ✅ Yes |
| JSON output | ✅ Yes | ✅ Yes | ✅ Yes |
| JUnit XML output | ✅ Yes | ❌ No | ✅ Yes |
| Language | Python | Go | Go |
| License | Apache 2.0 | MIT | Apache 2.0 |
| Standalone Docker image | ✅ Yes | ❌ No | ✅ Yes |
Installation & Deployment
Checkov
Via pip (recommended):
| |
Via Docker:
| |
Docker Compose for a persistent scanning service:
| |
Trivy (includes tfsec engine)
Via package manager (Debian/Ubuntu):
| |
Via Docker:
| |
Docker Compose with persistent vulnerability database:
| |
Scanning Terraform Files
Checkov: Scanning a Terraform Project
| |
Trivy: Scanning the Same Terraform Project
| |
Example Scan Output
A typical Checkov scan of a Terraform project with an unencrypted S3 bucket:
| |
A Trivy scan of the same configuration:
| |
Scanning Kubernetes Manifests
Checkov: Kubernetes YAML
| |
Trivy: Kubernetes YAML
| |
Scanning a Deployment with Privileged Container
Given a Kubernetes deployment that runs a privileged container:
| |
Checkov reports:
CKV_K8S_25: Minimize the admission of privileged containers — FAILEDCKV_K8S_38: Ensure that Service Account Tokens are only mounted where necessary — FAILED
Trivy reports:
KSV001: Privileged container detected — HIGHKSV009: Container running as root — MEDIUM
CI/CD Pipeline Integration
GitHub Actions
Checkov:
| |
Trivy:
| |
GitLab CI
| |
Jenkins Pipeline
| |
Choosing the Right Scanner
The choice depends on your team’s needs and existing toolchain:
Choose Checkov if:
- You need the widest IaC format support (Terraform, CloudFormation, ARM, Bicep, Serverless, OpenAPI, Dockerfile, Kubernetes)
- Your team prefers Python for custom policy development
- You want a mature, dedicated IaC scanning tool with 900+ built-in policies
- You need fine-grained policy controls with soft/hard fail modes
Choose Trivy (with tfsec engine) if:
- You want a single scanner for containers, IaC, Kubernetes, and SBOM
- Your team already uses Trivy for container image scanning
- You prefer Go-based tools for faster execution
- You need Rego-based custom policies (compatible with OPA/Gatekeeper)
- You want active development — tfsec’s engine is maintained within Trivy
Note: Standalone tfsec is in maintenance mode. For new deployments, use Trivy’s trivy config command, which includes the full tfsec scanning engine plus additional capabilities.
Both tools run entirely locally, require no cloud connectivity, and integrate seamlessly into self-hosted CI/CD pipelines. For teams also managing container security, Trivy offers the most comprehensive single-tool approach — see our SBOM and dependency tracking guide for a deeper look at Trivy’s software bill of materials capabilities.
FAQ
Can Checkov and Trivy scan Terraform Plan files?
Yes. Both tools accept Terraform Plan JSON output. Run terraform plan -out=tfplan && terraform show -json tfplan > tfplan.json, then pass the JSON file to either checkov -f tfplan.json or trivy config tfplan.json. This lets you catch misconfigurations before applying any changes to your infrastructure.
Is tfsec still maintained as a standalone project?
No. tfsec was merged into Trivy in 2023 and the standalone repository is in maintenance mode. The tfsec scanning engine is fully integrated into trivy config, so all existing tfsec checks continue to work. New development happens within the Trivy project.
Which tool has better Kubernetes scanning coverage?
Trivy generally provides more comprehensive Kubernetes scanning because it covers not just YAML manifests but also Helm charts, Kustomize overlays, and live cluster resources. Checkov has strong Kubernetes policy coverage with 100+ dedicated checks, but Trivy’s integration with the tfsec engine and its own native Kubernetes policies gives it a broader total.
Can I suppress false positives in these scanners?
Yes. Checkov supports inline suppression comments in Terraform files (# checkov:skip=CKV_AWS_20:reason), and both tools support ignore files. Checkov uses .checkov.yaml or CLI flags, while Trivy uses .trivyignore (compatible with tfsec’s .tfsecignore). Suppressions should always include a justification comment for auditability.
Do these scanners work in air-gapped environments?
Checkov requires Python dependencies to be installed, which may need offline package mirroring. Trivy downloads a vulnerability database on first run but can operate in offline mode with trivy config --offline-scan for IaC scanning specifically — no database download is needed for configuration checks. Both tools can run fully disconnected once installed.
How do I write custom security policies?
Checkov supports Python and YAML policy definitions. You create a Python class extending BaseResourceCheck or write a YAML rule with Rego-like conditions. Trivy uses Rego exclusively — write .rego files in a policy directory and pass them with --policy or place them in .trivy/policy/. Rego policies are portable between Trivy, OPA, and Gatekeeper.