Agent Native

iac-security

This skill scans Infrastructure as Code files for security misconfigurations across Terraform, Kubernetes, CloudFormation, and Azure ARM templates using Snyk.

by SnykOfficial publisherNot reviewed

Identity proven by GitHub's verified organisation badge (snyk)

Agents
Claude Code, Codex, Cursor, Gemini CLI, GitHub Copilot, OpenCode, claude.ai and API
License
Apache-2.0 (permissive)
Pin
691f03cpinned Oct 9, 2026
Context cost
about 2,100 tokenswhen the skill loads
GitHub stars
66on snyk/studio-recipes
Scripts
None found

What it does

“Infrastructure as Code security scanning for Terraform, Kubernetes, CloudFormation, and Azure ARM. Detects misconfigurations, security risks, and compliance violations before deployment. Use when: - User asks to scan Terraform files or modules - User mentions "infrastructure security" or "IaC scan" - User is working with Kubernetes manifests - User asks about CloudFormation or ARM template security - Agent is generating or modifying infrastructure code”
The author's description, from SKILL.md

Generated summary from the skill's own text

This skill scans Infrastructure as Code files for security misconfigurations across Terraform, Kubernetes, CloudFormation, and Azure ARM templates using Snyk. It detects security risks and compliance violations before deployment, analyzes findings by severity, and provides remediation guidance with secure code examples.

When to use it

  • Scanning Terraform files or modules for infrastructure vulnerabilities
  • Checking Kubernetes manifests for security misconfigurations and policy violations
  • Validating CloudFormation or ARM templates before deployment
  • Preventing security issues in infrastructure code before production

When not to

  • Scanning application source code rather than infrastructure definitions
  • When Snyk MCP server connection or authenticated account is unavailable
  • Addressing runtime security issues already in production environments

Install

These commands install from the publisher's repository and need no account.

skills CLI

npx skills add snyk/studio-recipes --skill iac-security

Installs from the repository's default branch, which may have changed since the commit we checked.

GitHub CLI 2.90 or later

gh skill install snyk/studio-recipes iac-security@691f03ce1b74d16514686601d4cb1b033a492518

Installs the commit we checked (691f03c).

Copy by hand

Download the folder at 691f03c and put it in .claude/skills/iac-security for Claude Code and in .agents/skills/iac-security for Codex, Cursor, Gemini CLI, GitHub Copilot and OpenCode.

Skill folder on GitHub at 691f03c

Copy for your agent

A prompt for any coding agent. It installs this skill from GitHub at the pinned commit, copies the files as they are, and runs nothing unless you ask.

Prompt

Install the agent skill "iac-security" by Snyk.

Source, pinned to commit 691f03ce1b74d16514686601d4cb1b033a492518:
https://github.com/snyk/studio-recipes/tree/691f03ce1b74d16514686601d4cb1b033a492518/command_directives/synchronous_remediation/skills/iac-security

1. Download that folder at exactly this commit. Do not use the default branch.
2. Copy every file unchanged, keeping the folder structure, into .claude/skills/iac-security/ for Claude Code and .agents/skills/iac-security/ for Codex, Cursor, Gemini CLI, GitHub Copilot and OpenCode. Create the folders if they do not exist.
3. Do not edit the files, and do not run any script in the folder unless I ask you to.
4. When you are done, list the files you copied and where you put them.

Listing and checks: https://www.agentnative.dev/skills/snyk/iac-security

SKILL.md at the pin

---
name: iac-security
description: |
  Infrastructure as Code security scanning for Terraform, Kubernetes, CloudFormation, and Azure ARM.
  Detects misconfigurations, security risks, and compliance violations before deployment. Use when:
  - User asks to scan Terraform files or modules
  - User mentions "infrastructure security" or "IaC scan"
  - User is working with Kubernetes manifests
  - User asks about CloudFormation or ARM template security
  - Agent is generating or modifying infrastructure code
allowed-tools: "mcp_snyk_snyk_iac_scan Read Write Edit Bash Grep"
license: Apache-2.0
compatibility: |
  Requires Snyk MCP server connection and authenticated Snyk account.
  Supports Terraform (.tf), Kubernetes (YAML), AWS CloudFormation, and Azure ARM templates.
  Optional: Terraform CLI for plan-based scanning.
metadata:
  author: Snyk
  version: 1.0.0
---

# Infrastructure as Code Security

Comprehensive security scanning for Infrastructure as Code to catch misconfigurations before they become production vulnerabilities.

**Core Principle**: Security issues are cheaper to fix in code than in production.

---

## Quick Start

```
1. Identify IaC files (Terraform, K8s, CloudFormation, ARM)
2. Run snyk_iac_scan on the directory
3. Analyze misconfigurations by severity
4. Provide secure configuration alternatives
```

---

## Supported IaC Formats

| Platform | File Types |
|----------|-----------|
| **Terraform** | `.tf`, `.tf.json`, `.tfvars` |
| **Terraform Plan** | JSON plan output (`terraform show -json`) |
| **Kubernetes** | `.yaml` / `.yml` with `apiVersion` + `kind` |
| **Helm** | Chart templates (requires `Chart.yaml`) |
| **AWS CloudFormation** | `.json` / `.yaml` with `AWSTemplateFormatVersion` |
| **Azure ARM** | `.json` with `$schema` ARM URL |
| **Serverless Framework** | `serverless.yml` |

---

## Phase 1: Discovery

**Goal**: Identify all IaC files that need scanning.

Check for these indicators to confirm IaC type:

- **Terraform**: `.tf` files, `terraform.tfstate`, `provider` blocks
- **Kubernetes**: YAML with `apiVersion`/`kind`, directories named `k8s`, `manifests`
- **CloudFormation**: `AWSTemplateFormatVersion` key, `Resources` section with AWS types
- **Azure ARM**: `$schema` containing `deploymentTemplate`

Then determine scan scope: single file, directory, or recursive.

---

## Phase 2: Execute Scan

**Goal**: Run appropriate IaC security scan.

### Basic Scan

```
Run snyk_iac_scan with:
- path: <directory or file path>
```

### Terraform with Variables

```
Run snyk_iac_scan with:
- path: <terraform directory>
- var_file: <path to .tfvars if using variables>
```

### Terraform Plan (more accurate)

```bash
terraform plan -out=tfplan
terraform show -json tfplan > tfplan.json
```

```
Run snyk_iac_scan with:
- path: tfplan.json
- scan: "planned-values"  # or "resource-changes"
```

### Custom Rules

```
Run snyk_iac_scan with:
- path: <directory>
- rules: <path to custom rules bundle>
```

---

## Phase 3: Analyze Results

**Goal**: Understand and categorize misconfigurations.

### Severity Assessment

| Severity | Risk Level | Examples |
|----------|------------|----------|
| **Critical** | Immediate risk | Public S3, open security groups |
| **High** | Significant risk | Missing encryption, excessive perms |
| **Medium** | Moderate risk | Missing logging, broad IAM |
| **Low** | Best practice | Missing tags, suboptimal config |

### Generate Summary

```
## IaC Security Scan Results

### Overview
| Severity | Count | Status |
|----------|-------|--------|
| Critical | X | 🔴 Block |
| High | Y | 🟠 Fix Required |
| Medium | Z | 🟡 Recommended |
| Low | W | 🔵 Optional |

### Critical Issues
| Resource | Issue | Location |
|----------|-------|----------|
| aws_s3_bucket.data | Public access enabled | main.tf:45 |
| aws_security_group.web | Open to 0.0.0.0/0 on port 22 | network.tf:23 |

### High Issues
| Resource | Issue | Location |
|----------|-------|----------|
| aws_rds_instance.db | Encryption not enabled | database.tf:12 |
```

### Categorize by Domain

Group issues for easier remediation:

- **Network Security**: Security groups, Network ACLs, Load balancer config, VPC settings
- **Data Protection**: Encryption at rest/in transit, Backup configuration, Key management
- **Access Control**: IAM policies, Service accounts, RBAC settings, API permissions
- **Logging & Monitoring**: CloudTrail/audit logs, Access logging, Alerting config

---

## Phase 4: Remediation

**Goal**: Provide secure configuration fixes. Apply the pattern below to each finding; representative examples follow.

### Terraform Fixes

#### S3 Bucket — Block Public Access

```hcl
# Insecure
resource "aws_s3_bucket" "data" {
  bucket = "my-bucket"
}

# Secure
resource "aws_s3_bucket" "data" {
  bucket = "my-bucket"
}

resource "aws_s3_bucket_public_access_block" "data" {
  bucket = aws_s3_bucket.data.id

  block_public_acls       = true
  block_public_policy     = true
  ignore_public_acls      = true
  restrict_public_buckets = true
}
```

#### Security Group — Restrict Access

```hcl
# Insecure - open to world
resource "aws_security_group" "web" {
  ingress {
    from_port   = 22
    to_port     = 22
    protocol    = "tcp"
    cidr_blocks = ["0.0.0.0/0"]  # BAD
  }
}

# Secure - restricted to VPN/internal range
resource "aws_security_group" "web" {
  ingress {
    from_port   = 22
    to_port     = 22
    protocol    = "tcp"
    cidr_blocks = ["10.0.0.0/8"]
  }
}
```

#### RDS — Enable Encryption

```hcl
# Secure
resource "aws_db_instance" "main" {
  engine              = "postgres"
  instance_class      = "db.t3.micro"
  storage_encrypted   = true
  kms_key_id          = aws_kms_key.rds.arn
  deletion_protection = true
}
```

### Kubernetes Fixes

#### Pod Security — Non-Root User & Resource Limits

```yaml
apiVersion: v1
kind: Pod
spec:
  securityContext:
    runAsNonRoot: true
    runAsUser: 1000
  containers:
  - name: app
    image: myapp
    securityContext:
      allowPrivilegeEscalation: false
      readOnlyRootFilesystem: true
      capabilities:
        drop:
          - ALL
    resources:
      limits:
        cpu: "500m"
        memory: "512Mi"
      requests:
        cpu: "200m"
        memory: "256Mi"
```

#### Network Policy — Restrict Traffic

```yaml
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
  name: app-network-policy
spec:
  podSelector:
    matchLabels:
      app: myapp
  policyTypes:
  - Ingress
  - Egress
  ingress:
  - from:
    - namespaceSelector:
        matchLabels:
          name: allowed-namespace
```

### CloudFormation Fixes

#### S3 Bucket — Encryption & Public Access Block

```yaml
Resources:
  DataBucket:
    Type: AWS::S3::Bucket
    Properties:
      BucketEncryption:
        ServerSideEncryptionConfiguration:
          - ServerSideEncryptionByDefault:
              SSEAlgorithm: aws:kms
              KMSMasterKeyID: !Ref DataBucketKey
      PublicAccessBlockConfiguration:
        BlockPublicAcls: true
        BlockPublicPolicy: true
        IgnorePublicAcls: true
        RestrictPublicBuckets: true
```

---

## Phase 5: Verification

**Goal**: Confirm fixes are effective.

### Re-scan After Changes

```
Run snyk_iac_scan with:
- path: <same directory>
```

For Terraform, regenerate and scan the plan:

```bash
terraform plan -out=tfplan.new
terraform show -json tfplan.new > tfplan.new.json
```

### Report Improvements

```
## Fix Verification

| Severity | Before | After | Change |
|----------|--------|-------|--------|
| Critical | 2 | 0 | -2 ✅ |
| High | 5 | 1 | -4 ✅ |
| Medium | 8 | 6 | -2 ✅ |

### Remaining Issues
- 1 High: Third-party module - opened issue
- 6 Medium: Accepted risk (documented)
```

---

## Best Practices

### Prevention

1. **Scan in CI/CD**: Fail builds with critical issues
2. **Pre-commit hooks**: Catch issues before commit
3. **Module security**: Scan reusable modules
4. **Policy as code**: Define custom rules for org standards

### Policy File Usage

Create `.snyk` to manage exceptions:

```yaml
ignore:
  SNYK-CC-TF-123:
    - '*':
        reason: 'Accepted risk - internal development environment'
        expires: 2025-06-01
        created: 2024-01-15
```

### Custom Rules

For organization-specific requirements:

1. Write rules in Rego (OPA) format
2. Bundle as `.tar.gz`
3. Pass to scan with `--rules` option

---

## Error Handling

| Error | Solutions |
|-------|-----------|
| **Could not read Terraform state** | Run `terraform init`; check state backend; scan `.tf` files directly |
| **Invalid HCL syntax** | Run `terraform validate`; check syntax; ensure all variables are defined |
| **Could not parse plan file** | Regenerate with `terraform show -json`; check Terraform version compatibility; verify JSON validity |

---

## Constraints

1. **Scan before apply**: Never apply unscanned IaC
2. **Block on critical**: Critical issues must be fixed
3. **Document exceptions**: Use `.snyk` policy for accepted risks
4. **Validate plans**: Prefer plan scanning over file scanning for Terraform
5. **Continuous monitoring**: Re-scan when dependencies update

From snyk/studio-recipes at 691f03c, shown as plain text under its license: Apache-2.0 (permissive). The license text is in command_directives/synchronous_remediation/skills/iac-security/SKILL.md.

View SKILL.md on GitHub at 691f03c

Files

3 files, 24 KB in total. Each file has a sha256 in the pin's manifest; the first 12 characters are shown.

Skill folder on GitHub at 691f03c
All 34 skills from Snyk

More from Snyk

  • algorithmic-art

    This skill generates algorithmic art using p5.js by first creating a computational philosophy describing the generative aesthetic, then implementing it as an…

    Contains scripts

    Claude Code, Codex, Cursor +3 · about 4.8K tokens · pinned 6 days ago

  • brand-guidelines

    This skill applies Anthropic's official brand identity to artifacts by setting specific colors, typography, and design standards.

    Claude Code, Codex, Cursor +4 · about 480 tokens · pinned 6 days ago

  • canary-project-skill

    This is a test fixture skill used by the canary testing system to verify that the agent-scan inspect command properly detects project-scoped skills located in…

    Claude Code, Codex, Cursor +4 · about 45 tokens · pinned 6 days ago

  • canvas-design

    This skill helps agents create visual art and design work as PNG or PDF files by first developing a design philosophy or aesthetic movement, then expressing…

    Claude Code, Codex, Cursor +4 · about 2.9K tokens · pinned 6 days ago

  • doc-coauthoring

    This skill guides users through a structured three-stage workflow for co-authoring documentation, proposals, specs, and similar structured content.

    Claude Code, Codex, Cursor +4 · about 3.8K tokens · pinned 6 days ago

  • docx

    This skill enables the agent to create, edit, and analyze Word documents (.docx files) with support for tracked changes, comments, and formatting preservation.

    Contains scripts

    Claude Code, Codex, Cursor +3 · about 2.4K tokens · pinned 6 days ago

All Security skills
  • code-security

    This skill provides comprehensive security guidelines for writing secure code across 15+ languages, covering OWASP Top 10 vulnerabilities and infrastructure…

    by SemgrepOfficial publisher

    Claude Code, Codex, Cursor +4 · about 1.1K tokens · pinned 6 days ago

  • container-security

    This skill scans Docker container images for OS package vulnerabilities, application dependencies, and Dockerfile configuration issues using Snyk.

    by SnykOfficial publisher

    Claude Code, Codex, Cursor +4 · about 2.2K tokens · pinned 6 days ago

  • claude-security

    Scans your repository for security issues using Claude, examines code changes or commits for vulnerabilities, and generates patch files to fix findings.

    by AnthropicOfficial publisher

    Claude Code · about 1K tokens · pinned 6 days ago

  • sensitive-logging-audit

    The skill helps audit and fix sensitive data leaks in Python SDK logging, exceptions, and telemetry by collecting candidate sinks, manually tracing values…

    by OpenAIOfficial publisher

    Contains scripts

    Claude Code, Codex, Cursor +3 · about 970 tokens · pinned 6 days ago

  • security-audit

    This skill guides security audits of codebases, APIs, and services by finding vulnerabilities that cross real trust boundaries.

    by CloudflareOfficial publisher

    Contains scripts

    Claude Code · about 5.4K tokens · pinned 6 days ago

  • assess-patch-risk

    This skill analyzes patch artifacts to assess their program impact, regression risk, and suitability for automated merging.

    by OpenAIOfficial publisher

    Codex · about 2.3K tokens · pinned 6 days ago

Open roles at Snyk

1 open role on the jobs board

The skills listed here are third-party software, collected from public GitHub repositories as a catalog of recent skills and provided as is. Agent Native does not write or control them and is not responsible for any harm, loss or damage caused by installing or using them. Labels and checks describe what we saw at one commit and are not a guarantee. Read a skill's files before you run it. Terms of use