| name | performing-container-security-scanning-with-trivy |
| description | Scan container images, filesystems, and Kubernetes manifests for vulnerabilities, misconfigurations, exposed secrets, and license compliance issues using Aqua Security Trivy with SBOM generation and CI/CD integration. |
| domain | cybersecurity |
| subdomain | container-security |
| tags | ["trivy","container-security","vulnerability-scanning","sbom","docker","kubernetes","devsecops","supply-chain"] |
| version | 1.0 |
| author | mahipal |
| license | Apache-2.0 |
| nist_csf | ["PR.PS-01","PR.IR-01","ID.AM-08","DE.CM-01"] |
Performing Container Security Scanning with Trivy
Overview
Trivy is an open-source security scanner by Aqua Security that detects vulnerabilities in OS packages and language-specific dependencies, infrastructure-as-code misconfigurations, exposed secrets, and software license issues across container images, filesystems, Git repositories, and Kubernetes clusters. Trivy generates Software Bill of Materials (SBOM) in CycloneDX and SPDX formats for supply chain transparency. This skill covers comprehensive container image scanning, CI/CD pipeline integration, Kubernetes operator deployment, and scan result triage for security operations.
When to Use
- When conducting security assessments that involve performing container security scanning with trivy
- When following incident response procedures for related security events
- When performing scheduled security testing or auditing activities
- When validating security controls through hands-on testing
Coverage Gaps & Validation
A green Trivy run often means "found nothing where it looked", not "image is clean". Know what the defaults skip:
- Single scanner enabled: plain
trivy image runs vuln only - misconfigs, hardcoded secrets, and license issues are silently uncovered. Use --scanners vuln,misconfig,secret,license when you mean a full audit.
--severity / --ignore-unfixed hide real risk: filtering to CRITICAL,HIGH drops exploitable MEDIUMs, and --ignore-unfixed hides CVEs with no patch yet (still exploitable). Report what was filtered.
- App dependencies vs OS packages: Trivy finds language libs only if the lockfile/manifest is in the image; vendored or statically linked deps and binaries built
FROM scratch/distroless can yield few or zero results - a false sense of safety.
- Layer scope and image drift: default
--scope squashed misses secrets in intermediate layers (use all-layers); and the scanned image tag can differ from what's actually running in the cluster.
Validate completeness: confirm the DB is current (trivy image --download-db-only / check --cache-dir age) - a stale DB misses new CVEs. Re-run with all scanners and no severity filter to gauge true counts, diff against the previously deployed digest, and for distroless images cross-check with an SBOM (--format cyclonedx) so you know which components were actually enumerated rather than skipped.