Skip to content

DefaultRisk v0.1.0 — Terraform Plan Scanner for Risky Cloud Defaults - #1

Open
sidshas03 wants to merge 1 commit into
mainfrom
feature/v0.1.0-release
Open

sidshas03 wants to merge 1 commit into
mainfrom
feature/v0.1.0-release

Conversation

@sidshas03

Copy link
Copy Markdown
Owner

What is this about?

DefaultRisk is a command-line tool that scans Terraform plan JSON files and flags risky cloud defaults — the security-relevant settings that teams forget to configure, leaving inherited provider defaults in place.

Most IaC scanners catch what you explicitly wrote wrong. This tool catches what you never wrote at all.

Architecture

The pipeline is straightforward: parse the plan, run rules, produce output.

Architecture

  • Plan Loader reads terraform show -json output and extracts resources with their effective configuration.
  • Rule Engine checks each resource against 15 detection rules across 6 AWS resource types.
  • Reporter formats findings as console text, JSON, or SARIF v2.1.0 (for GitHub code scanning).
  • CI Gate returns exit code 1 if any finding meets the severity threshold, blocking the deployment.

What it catches

Rules Overview

15 rules covering the defaults that actually cause breaches:

Category Rules What gets flagged
S3 DR-S3-001 to 004 Missing public access block, no encryption, no versioning, no logging
Security Groups DR-SG-001 to 003 SSH/RDP open to 0.0.0.0/0, all ports exposed to the internet
RDS DR-RDS-001 to 003 Publicly accessible, no storage encryption, 1-day backup retention
EBS DR-EBS-001 Unencrypted volumes and root devices
ECR DR-ECR-001 to 002 Scan on push disabled, mutable image tags
IAM DR-IAM-001 to 002 Wildcard Action:* Resource:*, iam:PassRole on *

Sample output

Console Output

Every finding includes:

  • What the provider defaults to when the field is omitted
  • Why that default is risky in plain English
  • A copy-paste Terraform snippet to fix it
  • Machine-readable evidence for automation

How to run

pip install -e .
defaultrisk scan examples/plans/insecure_s3.plan.json

No Terraform installation needed — example plan JSONs are committed in the repo.

Three output formats:

defaultrisk scan plan.json                             # console (human readable)
defaultrisk scan plan.json --format json --out r.json  # JSON (structured)
defaultrisk scan plan.json --format sarif --out r.sarif # SARIF (GitHub code scanning)

CI integration

- run: |
    pip install defaultrisk
    defaultrisk scan tfplan.json --severity-threshold high
# exits 1 if high/critical findings present → fails the pipeline

Tests

22 tests covering plan loading, all rule modules (positive and negative cases), all three output formats, severity gating, and golden output comparison.

tests/test_smoke.py   22 passed in 0.01s

Limitations

  • AWS only for now. Azure and GCP rules are planned.
  • Static analysis only — does not connect to live cloud accounts.
  • Each resource is evaluated independently. Cross-resource reachability scoring is on the roadmap.
  • Rule coverage is not exhaustive. We have prioritised the defaults that cause the most real-world damage.

Roadmap

  • Azure rules (Storage Account, NSG, SQL Database)
  • GCP rules (GCS, Firewall, Cloud SQL)
  • Cross-resource reachability scoring
  • Intent inference from naming and tagging patterns
  • Plugin system for custom rules

Made with Cursor

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant