Skip to content
Skillpedia
Agents35k · #6196

scanning-iac-and-images-with-trivy

Helps your agent check the security of container images and infrastructure code. It finds flaws before they cause problems.

What it does

This tool checks program images (like those used in containers), infrastructure configuration files (like Terraform or Kubernetes), and code for security issues. It looks for known flaws, incorrect settings, and sensitive information that might have been accidentally left exposed.

When to use it

  • ✓When building a new program and wanting to ensure it's secure before putting it into use.
  • ✓When making changes to how technology infrastructure is set up and wanting to verify the changes are safe.
  • ✓When wanting to check for exposed sensitive information (like passwords or keys) in code or configuration files.

Example of what to ask your AI

“Scan the container image 'my-app:latest' for vulnerabilities and misconfigurations.”

Want more? Open the sections below.

How to use

The easiest way: copy the message below and paste it into Claude, ChatGPT, Cursor or any AI. It reads the skill and follows the instructions.

Skill link

https://github.com/mukul975/Anthropic-Cybersecurity-Skills/blob/main/skills/scanning-iac-and-images-with-trivy/SKILL.md

Ready-to-paste message

Use this skill to help me: https://github.com/mukul975/Anthropic-Cybersecurity-Skills/blob/main/skills/scanning-iac-and-images-with-trivy/SKILL.md Read the SKILL.md file at that link and follow its instructions for my task.
How it works

The tool uses a program called Trivy to analyze files and images. It compares what it finds against databases of known issues and security rules to identify risks.

Installation

Easiest way: copy the skill link and paste it into Claude, ChatGPT or Cursor asking it to follow the instructions.

In the terminal (Claude Code, Codex, Cursor), in your project folder:

npx skills add mukul975/Anthropic-Cybersecurity-Skills --skill scanning-iac-and-images-with-trivy

Or download just the file:

curl -L https://raw.githubusercontent.com/mukul975/Anthropic-Cybersecurity-Skills/main/skills/scanning-iac-and-images-with-trivy/SKILL.md -o SKILL.md
Technical content (original SKILL.md)

Original text by the author, straight from GitHub.

Scanning IaC and Images with Trivy

Overview

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:

  • vuln — OS package and language-dependency vulnerability detection (CVE matching against the Trivy vulnerability DB).
  • misconfig — Infrastructure-as-Code and configuration misconfiguration detection (Terraform, CloudFormation, Kubernetes manifests, Dockerfile, Helm) using built-in and custom Rego policies.
  • secret — Hard-coded secret/credential detection (API keys, tokens, private keys).
  • license — Software license identification and policy enforcement.

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.

When to Use

  • When integrating vulnerability and misconfiguration scanning into a CI/CD pipeline as a quality/security gate before images are pushed or infrastructure is applied.
  • When auditing container images in a registry for known CVEs prior to deployment.
  • When validating Terraform, CloudFormation, Kubernetes, Dockerfile, or Helm IaC for security misconfigurations.
  • When generating an SBOM (CycloneDX/SPDX) for supply-chain transparency and later re-scanning that SBOM for newly disclosed CVEs.
  • When scanning a running Kubernetes cluster for vulnerable workloads and misconfigured RBAC/resources.
  • When enforcing license compliance policy on dependencies.

Prerequisites

  • A Linux/macOS/Windows host or CI runner with network access to download the Trivy vulnerability database.
  • Docker (optional) if scanning local images by name or using the containerized Trivy.
  • Install Trivy (Aqua Security official methods):
# 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
  • For air-gapped or rate-limited environments, pre-download the DB with trivy image --download-db-only and the Java/policy bundles as needed.

Objectives

  • Scan a container image for OS and language vulnerabilities and fail the build above a severity threshold.
  • Scan IaC (Terraform/Kubernetes/Dockerfile) for misconfigurations.
  • Detect hard-coded secrets in a repository or filesystem.
  • Generate a CycloneDX or SPDX SBOM and re-scan it for vulnerabilities.
  • Emit SARIF for GitHub code scanning and JSON for programmatic gating.
  • Wire Trivy into a CI/CD pipeline with --exit-code to enforce policy.

MITRE ATT&CK Mapping

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.

Workflow

1. Scan a container image for vulnerabilities

…

FAQ

What are 'vulnerabilities'?

These are known security flaws in software that malicious actors could exploit to cause harm or steal information.

What are 'misconfigurations'?

These are errors in how systems or programs are set up, which can create security loopholes.

What are 'secrets'?

These are sensitive pieces of information like passwords, API keys, or tokens that should not be exposed in code or configuration files.

Details

Original description by the author

Scans container images, Infrastructure-as-Code (Terraform, CloudFormation, Kubernetes manifests, Dockerfile, Helm), filesystems, git repos, and SBOMs with Trivy's vuln, misconfig, secret, and license scanners. Use when building a CI/CD security gate that scans images before push, IaC before apply, or SBOMs for supply-chain weaknesses, and fails the build on policy violations.

repo: mukul975/Anthropic-Cybersecurity-Skills

Popularity

GitHub stars
35k
Ranking position
#6196
License
Apache-2.0
Updated
8/31/2026

Is this skill useful?

0

Sign in to vote.

Comments

  • …

More skills from this repository

Similar skills