segrep-iac scanner

Opt-in local IaC misconfiguration scanner for Terraform, Kubernetes, and Dockerfiles

Opt-in local IaC misconfiguration scanner for Segrep that detects security issues in Terraform, Kubernetes manifests, and Dockerfiles — no external binary required.

Why use segrep-iac

  • Detects 18 categories of IaC misconfigurations across Terraform, Kubernetes, and Dockerfiles.
  • Runs locally with zero dependencies — no Checkov or Kubescape binary required.
  • Flags publicly accessible resources, unencrypted storage, privilege escalation risks, and insecure container configurations.
  • Every finding maps to a CWE reference for compliance tracking.

Scanner behavior

segrep-iac runs as an opt-in scanner.

pnpm segrep scan . --scanners segrep-iac

It walks the scan root and applies rules against IaC files:

  • *.tf, *.hcl — Terraform files
  • *.yaml, *.yml — Kubernetes manifests and Docker Compose files
  • Dockerfile, Dockerfile.* — Dockerfiles

Rules

Terraform

Rule IDSeverityWhat it detects
iac-tf-s3-public-aclhighS3 bucket with acl = "public-read" or "public-read-write"
iac-tf-s3-no-versioningmediumS3 bucket without versioning enabled
iac-tf-ebs-unencryptedhighEBS volume without encryption
iac-tf-sg-open-cidrhighSecurity group with 0.0.0.0/0 ingress
iac-tf-rds-publiccriticalRDS instance with publicly_accessible = true

Kubernetes

Rule IDSeverityWhat it detects
iac-k8s-privilegedcriticalContainer with privileged: true
iac-k8s-allow-privilege-escalationhighContainer with allowPrivilegeEscalation: true
iac-k8s-run-as-roothighContainer running as root (runAsNonRoot: false)
iac-k8s-host-networkhighPod with hostNetwork: true
iac-k8s-host-pidhighPod with hostPID: true
iac-k8s-host-ipchighPod with hostIPC: true
iac-k8s-host-portmediumContainer with hostPort set
iac-k8s-image-latestmediumContainer image using :latest tag
iac-k8s-writable-root-fsmediumContainer with readOnlyRootFilesystem: false

Dockerfile

Rule IDSeverityWhat it detects
iac-dockerfile-run-as-roothighUSER root or missing USER directive
iac-dockerfile-latest-tagmediumFROM using :latest tag
iac-dockerfile-add-coplowADD used instead of COPY
iac-dockerfile-curl-pipe-shhigh`curl ...
iac-dockerfile-privileged-portmediumExposing privileged ports (< 1024)

Finding output

Each finding includes:

  • ruleId — the matched rule (e.g., iac-tf-s3-public-acl)
  • cweId — CWE reference
  • line — line number where the issue was found
  • snippet — the matched line

Example finding:

{
  "id": "segrep-iac:iac-tf-s3-public-acl:main.tf:5",
  "title": "S3 bucket with public ACL",
  "severity": "high",
  "filePath": "main.tf",
  "scanner": "segrep-iac",
  "category": "iac",
  "ruleId": "iac-tf-s3-public-acl",
  "cweId": "CWE-284",
  "line": 5,
  "snippet": "acl = \"public-read\""
}

Policy integration

scanners:
  - segrep-iac

# Allowlist known-good findings by rule ID
allowlist:
  - iac-dockerfile-latest-tag

# Ignore test fixtures
ignore_paths:
  - "fixtures/**"
  - "**/*.test.*"

Examples

IaC only:

docker run --rm -v "$(pwd):/repo:ro" security-scanner:local \
  scan /repo --scanners segrep-iac

Combine with cloud scanning:

docker run --rm -v "$(pwd):/repo:ro" security-scanner:local \
  scan /repo --scanners segrep-iac,segrep-cloud --format json

Fail CI on any high or critical misconfiguration:

docker run --rm -v "$(pwd):/repo:ro" security-scanner:local \
  scan /repo --scanners segrep-iac --fail-on high