/cybersecurity-skills:scanning-iac-and-images-with-trivyfrom cybersecurity-skills
Scans container images, IaC (Terraform, CloudFormation, K8s, Dockerfile, Helm), filesystems, git repos, and SBOMs with Trivy for vulnerabilities, misconfigurations, secrets, and license issues. Use as a CI/CD security gate that fails builds on policy violations.
Ships in cybersecurity-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.
Read when SKILL.md points to them; scripts run unread.
Trivy (by Aqua Security) is a comprehensive, open-source security scanner that finds vulnerabilities (CVEs), misconfigurations (IaC), secrets, software licenses, and software supply-chain weaknesses across a wide range of targets: container images, filesystems, Git repositories, virtual machine images, Kubernetes clusters, and SBOM documents. It is widely adopted as a "shift-left" gate in CI/CD pipelines because it is fast, runs as a single static binary, requires no agent, and supports machine-readable output formats (JSON, SARIF, CycloneDX, SPDX) for integration with code-scanning dashboards.
Trivy bundles four primary scanners that can be toggled with --scanners:
This skill covers building a Trivy-based scanning workflow that gates a CI/CD pipeline: scanning images before push, scanning IaC before apply, generating and re-scanning SBOMs, and failing builds on policy violations. Detecting these weaknesses defends against the MITRE ATT&CK technique T1525 (Implant Internal Image), where adversaries plant malicious or vulnerable images in a registry to be deployed across the environment.
# Debian/Ubuntu (APT repository)
sudo apt-get install -y wget gnupg
wget -qO - https://aquasecurity.github.io/trivy-repo/deb/public.key | gpg --dearmor | sudo tee /usr/share/keyrings/trivy.gpg > /dev/null
echo "deb [signed-by=/usr/share/keyrings/trivy.gpg] https://aquasecurity.github.io/trivy-repo/deb generic main" | sudo tee /etc/apt/sources.list.d/trivy.list
sudo apt-get update
sudo apt-get install -y trivy
# RHEL/CentOS (YUM repository), macOS (Homebrew), and install script
brew install trivy
curl -sfL https://raw.githubusercontent.com/aquasecurity/trivy/main/contrib/install.sh | sudo sh -s -- -b /usr/local/bin
# Containerized usage (no install)
docker run --rm -v /var/run/docker.sock:/var/run/docker.sock aquasec/trivy:latest image python:3.10-alpine
# Verify
trivy --version
trivy image --download-db-only and the Java/policy bundles as needed.--exit-code to enforce policy.| Technique ID | Name | Tactic | Relevance |
|---|---|---|---|
| T1525 | Implant Internal Image | Persistence | Trivy detects vulnerable or malicious images/layers and embedded secrets before they are implanted in a registry and propagated to running workloads. |
Run a vulnerability-only scan of a registry image, restricting to high/critical findings and ignoring CVEs with no available fix:
trivy image \
--scanners vuln \
--severity HIGH,CRITICAL \
--ignore-unfixed \
--format table \
python:3.10-alpine
Scan an image saved as a tarball (useful when the image is built but not yet pushed):
docker save myorg/app:1.4.0 -o app.tar
trivy image --input app.tar --severity CRITICAL --format json --output app-vulns.json
Run vulnerability, misconfiguration, secret, and license scanners together:
trivy image \
--scanners vuln,misconfig,secret,license \
--severity MEDIUM,HIGH,CRITICAL \
myorg/app:1.4.0
Scan the image's embedded config (Dockerfile-equivalent build history and history secrets):
trivy image --image-config-scanners misconfig,secret myorg/app:1.4.0
Scan a directory of Terraform / Kubernetes / Dockerfile / Helm / CloudFormation for misconfigurations using the config target:
# Scan a Terraform / IaC directory
trivy config \
--severity HIGH,CRITICAL \
--format table \
./infra
# Scan with custom Rego policies and a specific policy namespace
trivy config \
--config-policy ./policies \
--policy-namespaces user \
./infra
Alternatively use the fs (filesystem) target with the misconfig scanner explicitly:
trivy fs --scanners misconfig,secret --severity HIGH,CRITICAL ./infra
Scan a local working tree (or remote repo) for vulnerabilities in lockfiles and hard-coded secrets:
# Local filesystem (dependencies + secrets)
trivy fs --scanners vuln,secret --severity HIGH,CRITICAL .
# Remote Git repository
trivy repository --scanners vuln,secret https://github.com/myorg/myrepo
Produce a CycloneDX SBOM from an image, then scan the SBOM itself for vulnerabilities (so a stored SBOM can be re-evaluated as new CVEs are disclosed):
# Generate CycloneDX SBOM
trivy image --format cyclonedx --output sbom.cdx.json myorg/app:1.4.0
# Generate SPDX SBOM
trivy image --format spdx-json --output sbom.spdx.json myorg/app:1.4.0
# Re-scan the SBOM for vulnerabilities later
trivy sbom --severity HIGH,CRITICAL sbom.cdx.json
Produce SARIF for GitHub Advanced Security / code scanning ingestion:
trivy image \
--format sarif \
--output trivy-results.sarif \
--severity HIGH,CRITICAL \
myorg/app:1.4.0
Use --exit-code 1 so the pipeline step fails when findings at or above the chosen severity are present. Separate the "report everything" run (exit 0) from the "enforce" run (exit 1):
# 1) Informational report (never fails the build)
trivy image --severity LOW,MEDIUM,HIGH,CRITICAL --exit-code 0 --format table myorg/app:1.4.0
# 2) Enforcement gate (fails build on HIGH/CRITICAL with a fix available)
trivy image \
--severity HIGH,CRITICAL \
--ignore-unfixed \
--exit-code 1 \
--format json --output gate.json \
myorg/app:1.4.0
Example GitHub Actions step using the official action:
- name: Run Trivy image scan (gate)
uses: aquasecurity/trivy-action@master
with:
image-ref: 'myorg/app:1.4.0'
format: 'sarif'
output: 'trivy-results.sarif'
severity: 'HIGH,CRITICAL'
ignore-unfixed: true
exit-code: '1'
Suppress accepted-risk findings with a .trivyignore file and keep the DB current:
# .trivyignore — one CVE/AVD/secret rule ID per line
echo "CVE-2023-12345" >> .trivyignore
echo "AVD-AWS-0089" >> .trivyignore
# Refresh DBs explicitly (useful for caching layers in CI)
trivy image --download-db-only
trivy image --download-java-db-only
# Scan a Kubernetes cluster (summary report)
trivy k8s --report summary --severity HIGH,CRITICAL cluster
| Tool / Resource | Purpose | Link |
|---|---|---|
| Trivy | Core scanner CLI | https://github.com/aquasecurity/trivy |
| Trivy Documentation | Official docs (targets, scanners, flags) | https://trivy.dev/latest/docs/ |
| trivy-action | GitHub Actions integration | https://github.com/aquasecurity/trivy-action |
| Trivy Operator | In-cluster Kubernetes continuous scanning | https://github.com/aquasecurity/trivy-operator |
| Trivy vulnerability DB | OSS vulnerability data source | https://github.com/aquasecurity/trivy-db |
| CycloneDX | SBOM standard emitted by Trivy | https://cyclonedx.org/ |
trivy --version reports a valid version.trivy config and misconfigurations reviewed.trivy sbom.--exit-code 1..trivyignore configured for accepted-risk findings with documented justification.What SKILL.md sets; muted values are Claude Code's defaults
npx claudepluginhub bfoxhound/anthropic-cybersecurity-skills --plugin cybersecurity-skills4 plugins ship this exact skill · first indexed Aug 2, 2026
815 skills in this plugin
/abusing-dpapi-for-credential-accessExtract and decrypt Windows DPAPI-protected secrets (Credential Manager, browser logins/cookies, Wi-Fi credentials, KeePass keys) online or offline using SharpDPAPI, SharpChrome, Mimikatz, or Impacket's dpapi.py, including domain-wide decryption via the DPAPI backup key. Use during authorized red-team credential-access engagements after gaining a foothold or when triaging DPAPI blobs pulled from a host./abusing-shadow-credentials-for-privescTake over Active Directory accounts by writing attacker-controlled public keys to msDS-KeyCredentialLink (Shadow Credentials) with pyWhisker, Whisker, or Certipy, then authenticate via PKINIT to recover the target's NT hash without a password reset. Use when BloodHound shows GenericWrite/GenericAll/AddKeyCredentialLink over a target, as a stealthier alternative to ForceChangePassword, during authorized red-team engagements./achieving-cmmc-level-2-compliancePrepare a defense-contractor environment for CMMC Level 2 certification: scope CUI and FCI, implement the 110 NIST SP 800-171 Rev 2 security requirements across 14 families, compute the SPRS score with the DoD Assessment Methodology, manage a compliant POA&M, and ready the organization for a C3PAO assessment. Use when an organization handles Controlled Unclassified Information (CUI) under a DoD contract, when a contract carries DFARS clause 252.204-7012/7019/7020/7021, when preparing for or responding to a CMMC assessment, when computing or improving an SPRS score, when building a System Security Plan or POA&M for 800-171, or when scoping which systems are in the CUI boundary. Keywords: CMMC, CMMC Level 2, NIST 800-171, SP 800-171 Rev 2, CUI, FCI, SPRS, DFARS 7012, C3PAO, POA&M, System Security Plan, DoD Assessment Methodology, 110 controls, defense industrial base, DIB, FedRAMP equivalency.Other plugins' skills for the same job