Stop security issues before they become breaches
ML-powered detection • AI-enhanced analysis • Real-world breach training
Quick Start • Why TerraSecure? • Features • Docs • vs Others
Click to expand
TerraSecure is an intelligent security scanner for Infrastructure as Code that combines machine learning with AI-powered analysis to detect misconfigurations before they reach production.
Unlike traditional rule-based tools, TerraSecure:
- Learns patterns using a pre-trained XGBoost model (92.45% accuracy)
- Explains impact with AI-generated business context and attack scenarios
- Reduces noise with 10.71% false positive rate (better than Checkov's 15%)
- Learns from real breaches including Capital One, Uber, and Tesla incidents
Think of it as having a security expert review your infrastructure—but automated and instant.
Traditional security scanners generate too many false positives. Security teams waste time investigating non-issues while real threats slip through.
|
Traditional existing tools
|
TerraSecure
|
BEFORE (Checkov):
! 147 issues found (22 false positives)
! Security team spends 4 hours triaging
! 3 real issues missed in the noise
AFTER (TerraSecure):
✓ 125 issues found (13 false positives)
✓ Security team spends 1 hour triaging
✓ All critical issues caught with AI context
✓ Developers get actionable fixes immediatelyAdd to .github/workflows/security.yml:
name: Security Scan
on: [push, pull_request]
permissions:
security-events: write
jobs:
terrasecure:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: JashwanthMU/TerraSecure@v2.0.0Results appear automatically in the GitHub Security tab.
docker run --rm -v $(pwd):/scan \
ghcr.io/jashwanthmu/terrasecure:latest /scangit clone https://github.com/JashwanthMU/TerraSecure.git
cd TerraSecure
pip install -r requirements.txt
python src/cli.py examples/vulnerableTerraSecure uses a three-layer detection architecture:
flowchart TB
subgraph Input["Input Layer"]
TF[Terraform Files]
HCL[HCL Configurations]
MOD[Terraform Modules]
end
subgraph Detection["Detection Engine"]
RULES[Rule Engine<br/>50+ Security Patterns]
ML[ML Model<br/>XGBoost 92% Accuracy]
FEAT[Feature Extractor<br/>50 Security Features]
end
subgraph AI["AI Enhancement"]
BEDROCK[AWS Bedrock<br/>Claude 3 Haiku]
FALLBACK[Expert Templates<br/>Real Breach Analysis]
CACHE[Response Cache<br/>90% Cost Savings]
end
subgraph Output["Output Formats"]
TEXT[Text Output<br/>Human-Readable]
JSON[JSON Output<br/>Automation-Ready]
SARIF[SARIF 2.1.0<br/>GitHub Security]
end
TF --> Detection
HCL --> Detection
MOD --> Detection
Detection --> |Findings|AI
AI --> Output
style Input fill:#e1f5ff
style Detection fill:#ffebee
style AI fill:#f3e5f5
style Output fill:#e8f5e9
1. PARSE → Extract resources and properties from Terraform files
2. DETECT → Apply 50+ security patterns + ML risk scoring
3. ANALYZE → AI generates business impact and remediation
4. OUTPUT → Format as Text/JSON/SARIF for humans or tools
Click to see ML training and inference pipeline
flowchart LR
subgraph Training[" Training Pipeline"]
DATA[265 SamplesReal Breaches]
FEATURES[50 SecurityFeatures]
MODEL[XGBoost5-Fold CV]
EXPORT[Model Export177KB]
DATA --> FEATURES
FEATURES --> MODEL
MODEL --> EXPORT
end
subgraph Inference[" Inference"]
RESOURCE[TerraformResource]
EXTRACT[FeatureExtraction]
PREDICT[RiskPrediction]
SCORE[Risk Score0.0 - 1.0]
RESOURCE --> EXTRACT
EXPORT --> PREDICT
EXTRACT --> PREDICT
PREDICT --> SCORE
end
style Training fill:#e3f2fd
style Inference fill:#fff8e1
Training Data:
- Capital One S3 breach (2019)
- Uber credential leak (2016)
- Tesla public bucket (2018)
- MongoDB ransomware (2017)
|
Pre-trained XGBoost Model
|
Real Breach Training
|
Every finding includes:
- Explanation - What's wrong and why it matters
- Business Impact - Financial, regulatory, and reputational risks
- Attack Scenario - How attackers exploit this (with real examples)
- Detailed Fix - Step-by-step remediation with code
| Format | Use Case | Features |
|---|---|---|
| Text | Human review | Colored output, AI insights |
| JSON | Automation | Machine-readable, scriptable |
| SARIF 2.1.0 | GitHub Security | Code scanning alerts, PR comments |
Network Security (12 patterns)
- Security groups open to 0.0.0.0/0
- SSH/RDP exposed to internet
- Unrestricted egress rules
- Missing network segmentation
- Default security groups in use
- VPC without Flow Logs
- ...and 6 more
Storage Security (15 patterns)
- Public S3 buckets
- Unencrypted S3/EBS/RDS
- Missing versioning
- No backup retention
- Public snapshots
- Cross-region replication disabled
- ...and 9 more
Identity & Access (10 patterns)
- Wildcard IAM permissions
- Root account usage
- Missing MFA
- Overly permissive policies
- Inline user policies
- ...and 5 more
Secrets Management (8 patterns)
- Hardcoded credentials
- Plaintext environment variables
- Unencrypted secrets
- Exposed API keys
- ...and 4 more
Monitoring & Compliance (5 patterns)
- CloudTrail disabled
- No VPC Flow Logs
- Missing CloudWatch alarms
- Access logging disabled
- Config rules not enabled
- Python 3.11+
- pip package manager
- 512MB RAM minimum
docker pull jashwanthmu/terrasecure:latest- uses: JashwanthMU/TerraSecure@v2.0.0git clone https://github.com/JashwanthMU/TerraSecure.git
cd TerraSecure
pip install -r requirements.txt
python src/cli.py --help# Scan current directory
terrasecure .
# Scan specific directory
terrasecure infrastructure/
# Scan single file
terrasecure main.tf# JSON output
terrasecure . --format json --output report.json
# SARIF for GitHub Security
terrasecure . --format sarif --output results.sarif
# Text with AI insights (default)
terrasecure .# Fail on critical issues
terrasecure . --fail-on critical
# Fail on high or critical
terrasecure . --fail-on high
# Fail on any finding
terrasecure . --fail-on any# Basic scan
docker run --rm -v $(pwd):/scan \
ghcr.io/jashwanthmu/terrasecure:latest /scan
# Generate SARIF report
docker run --rm \
-v $(pwd):/scan:ro \
-v $(pwd):/output \
ghcr.io/jashwanthmu/terrasecure:latest \
/scan --format sarif --output /output/results.sarif
# Fail on critical issues
docker run --rm -v $(pwd):/scan \
ghcr.io/jashwanthmu/terrasecure:latest \
/scan --fail-on critical- name: TerraSecure Scan
uses: JashwanthMU/TerraSecure@v2.0.0- name: Security Scan with Policy
uses: JashwanthMU/TerraSecure@v2.0.0
with:
path: 'infrastructure'
format: 'sarif'
fail-on: 'high'
upload-sarif: 'true'- name: Block on Critical
uses: JashwanthMU/TerraSecure@v2.0.0
with:
fail-on: 'critical'
# PR fails if critical issues foundClick to see example output
``` ╔════════════════════════════════════════════════════════════╗ ║ TerraSecure ║ ║ AI-Powered Terraform Security Scanner ║ ╚════════════════════════════════════════════════════════════╝Total Resources Scanned: 15 Resources Passed: 7 Issues Found: 8
Severity Breakdown: Critical: 2 High: 4 Medium: 2
[CRITICAL] S3 bucket with sensitive naming is publicly accessible Resource: aws_s3_bucket.customer_data File: infrastructure/storage.tf:12 ML Risk: 95% | Confidence: 92% Triggered: s3_public_acl, s3_encryption_disabled (+13 more)
━━━ AI-Enhanced Analysis ━━━
Explanation: This S3 bucket is configured with public access (acl = "public-read"), allowing anyone on the internet to discover and potentially access its contents. The bucket name suggests it contains sensitive customer data.
Business Impact: Public S3 buckets are the leading cause of cloud data breaches. Exposure could lead to: • Data theft affecting customer privacy • GDPR fines up to €20M or 4% of annual revenue • Reputational damage and loss of customer trust • Competitive intelligence leakage
Attack Scenario: Attackers use automated scanners (bucket-stream, S3Scanner) that continuously probe for public S3 buckets. Once discovered, they can enumerate all objects and download sensitive files within minutes.
Real Example: Capital One breach (2019) exposed 100M records through
misconfigured S3, resulting in $190M in settlements and fines.
Detailed Fix: Step 1: Change ACL to private acl = "private"
Step 2: Enable block public access
block_public_acls = true
block_public_policy = true
ignore_public_acls = true
restrict_public_buckets = true
Step 3: Enable server-side encryption
server_side_encryption_configuration {
rule {
apply_server_side_encryption_by_default {
sse_algorithm = "AES256"
}
}
}
</details>
### JSON Output (Automation)
<details>
<summary><b>Click to see JSON structure</b></summary>
```json
{
"total_resources": 15,
"passed": 7,
"stats": {
"CRITICAL": 2,
"HIGH": 4,
"MEDIUM": 2
},
"issues": [
{
"severity": "CRITICAL",
"resource_type": "aws_s3_bucket",
"resource_name": "customer_data",
"file": "infrastructure/storage.tf",
"line": 12,
"message": "S3 bucket with sensitive naming is publicly accessible",
"ml_risk_score": 0.95,
"ml_confidence": 0.92,
"triggered_features": [
"s3_public_acl",
"s3_encryption_disabled",
"s3_versioning_disabled"
],
"llm_explanation": "This S3 bucket is configured with public access...",
"llm_business_impact": "Public S3 buckets are the leading cause...",
"llm_attack_scenario": "Real Example: Capital One breach...",
"llm_detailed_fix": "Step 1: Change ACL to private..."
}
]
}
SARIF 2.1.0 format enables:
- Native github Security tab integration
- Code scanning alerts on files
- PR comments with fix suggestions
- Security dashboard metrics
| Metric | Value | Target | Status |
|---|---|---|---|
| Accuracy | 92.45% | >85% | Exceeds |
| Precision | 89.29% | >80% | Exceeds |
| Recall | 96.00% | >90% | Exceeds |
| F1 Score | 92.54% | >85% | Exceeds |
| False Positive Rate | 10.71% | <15% | Excellent |
| False Negative Rate | 4.00% | <5% | Excellent |
| Scan Speed | <100ms/resource | <200ms | Fast |
| Model Size | 177 KB | <1MB | Tiny |
Tested on:
- 10,000+ Terraform resources
- Multi-file configurations
- Nested modules
- Complex dependencies
Memory usage: <512MB RAM
| Feature | Checkov | Trivy | TerraSecure |
|---|---|---|---|
| Detection Method | Rules | Rules | ML + AI |
| Accuracy | ~85% | ~88% | 92.45% |
| False Positives | ~15% | ~12% | 10.71% |
| AI Explanations | No | No | Full Context |
| Business Impact | No | No | Financial + Regulatory |
| Attack Scenarios | No | No | Real Breaches |
| ML Risk Scoring | No | No | 50 Features |
| Real Breach Training | No | No | C1, Uber, Tesla |
| Fix Examples | Generic | Generic | Specific + Code |
| SARIF Output | Yes | Yes | Yes |
| GitHub Action | Yes | Yes | Yes |
| Docker | Yes | Yes | Yes |
| Offline Mode | Yes | Yes | Yes |
Choose TerraSecure if you want:
- Fewer false positives(10.7% vs 15%)
- AI explanations for stakeholders
- ML-based risk prioritization
- Context from real breaches
- Innovation in security tooling
Stick with Checkov/Trivy if you need:
- 5+ years of battle testing
- Very large scale(100k+ resources)
- Maximum rule coverage(breadth > depth)
Best Approach: Use TerraSecure + Checkov/Trivy together for comprehensive coverage!
name: Security
on: [push, pull_request]
permissions:
security-events: write
jobs:
terrasecure:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: JashwanthMU/TerraSecure@v2.0.0
with:
path: 'infrastructure'
fail-on: 'high'terrasecure:
image: ghcr.io/jashwanthmu/terrasecure:latest
script:
- terrasecure . --format json --output report.json
artifacts:
reports:
codequality: report.jsonpipeline {
agent any
stages {
stage('Security Scan') {
steps {
script {
docker.image('ghcr.io/jashwanthmu/terrasecure:latest').inside {
sh 'terrasecure . --format json'
}
}
}
}
}
}- task: Docker@2
inputs:
command: run
arguments: >
-v $(Build.SourcesDirectory):/scan
ghcr.io/jashwanthmu/terrasecure:latest
/scan --format sarifversion: 2.1
jobs:
security:
docker:
- image: ghcr.io/jashwanthmu/terrasecure:latest
steps:
- checkout
- run: terrasecure . --fail-on high- Quick Start Guide - Get started in 5 minutes
- Docker Guide - Container usage and deployment
- GitHub Action Guide - CI/CD integration
- Architecture - System design and ML model
- ML Model Training - How the model was built
- AI Enhancement - AWS Bedrock integration
- Custom Rules - Extend detection patterns
- SARIF Format - GitHub Security integration
Contributions welcomed!
- Bug reports - Found an issue? Open an issue
- Feature requests - Have an idea? Start a discussion
- Documentation - Improve our docs
- Code contributions - Fix bugs or add features
# Fork and clone
git clone https://github.com/YOUR_USERNAME/TerraSecure.git
cd TerraSecure
# Install dependencies
pip install -r requirements.txt
# Run tests
pytest
# Build ML model
python scripts/build_production_model.py- CVE Database - Vulnerability intelligence
- NIST NVD - Security advisories
- Public breach reports and post-mortems
- SARIF 2.1.0 - OASIS SARIF TC
- Terraform Best Practices
- AWS Security Best Practices
- Checkov - Pioneering IaC scanning
- Trivy - Comprehensive security scanner
- tfsec - Terraform static analysis
- XGBoost - ML framework
- scikit-learn - ML library
- AWS Bedrock - AI foundation models
- python-hcl2 - Terraform parsing
© 2026 Jashwanth M U.
