What is Threat Modeling as Code?
Threat modeling as code is the practice of treating threat models as machine-readable, version-controlled artifacts that evolve alongside your codebase. Just as Infrastructure as Code (IaC) transformed how we manage infrastructure, threat modeling as code transforms how we manage security analysis. It builds on established methodologies like STRIDE and PASTA.
Instead of static Word documents or whiteboard photos that become outdated by the next sprint, threat models are defined in YAML, JSON, or programmatic definitions. They're automatically generated, validated, and updated as part of your development workflow.
Key Principles
Why Traditional Threat Modeling Fails DevSecOps
Traditional threat modeling was designed for waterfall. Here's why it breaks in modern DevSecOps environments, and how code-based threat modeling solves each problem.
Manual and slow, often taking days to complete
Automated scans complete in seconds on every commit
Outdated by the next sprint
Threat models auto-update with architecture changes
Requires dedicated security experts
Any developer can define and review threat models
Doesn't scale across microservices
Scales to hundreds of services with declarative definitions
No integration with developer tooling
Native CI/CD, Git, and IDE integration
Results in static, unactionable documents
Generates actionable findings with remediation playbooks
How Aristiun Implements Threat Modeling as Code
Five core capabilities that make threat modeling a first-class citizen in your development workflow.
Architecture-as-Code
Define your system architecture in YAML or JSON. Aristiun generates detailed, architecture-specific threat models from declarative definitions. Skip the diagram sessions and manual guesswork.
Git-Native Threat Models
Threat models live alongside your source code. Version-controlled, diff-able, and PR-reviewable. Every change is tracked, every decision is auditable.
CI/CD Pipeline Integration
Runs a scan on every commit and blocks PRs that introduce critical threats. Deployment gates enforce threat model approval, with zero manual intervention.
IaC Analysis
Parse Terraform, CloudFormation, Kubernetes manifests, and Docker Compose files. Identify security threats based on actual infrastructure configuration, not assumptions.
API-First
REST API for programmatic threat model generation. Works with any toolchain, from custom scripts to enterprise orchestration platforms.
Pipeline Integration Examples
Drop-in configurations for the most popular CI/CD platforms. Add automated threat modeling to your pipeline in minutes.
name: Threat Model Scan
on: [push, pull_request]
jobs:
threat-model:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Run Aristiun Threat Model
uses: aristiun/threat-model-action@v2
with:
config: ./threat-model.yaml
fail-on: critical,high
output: threat-report.json
- name: Upload Report
uses: actions/upload-artifact@v4
with:
name: threat-report
path: threat-report.jsonInfrastructure as Code Threat Analysis
Aristiun parses your infrastructure definitions and identifies security threats based on actual configuration, before anything is deployed. Pair this with architecture-aware code security scanning for full coverage.
Terraform
Detects: Misconfigured security groups, public S3 buckets, missing encryption at rest, overly permissive IAM roles
CloudFormation
Detects: Unencrypted RDS instances, open CIDR blocks, missing VPC flow logs, insecure Lambda permissions
Kubernetes
Detects: Privileged containers, host network access, missing network policies, insecure service accounts
Docker Compose
Detects: Exposed ports, root containers, bind-mounted secrets, missing resource limits
# threat-model.yaml - IaC scanning configuration
sources:
terraform:
paths: ["./infra/terraform/**/*.tf"]
scan_modules: true
kubernetes:
paths: ["./k8s/**/*.yaml"]
namespaces: ["production", "staging"]
docker:
paths: ["./docker-compose*.yml"]
rules:
fail_on_severity: critical
ignore:
- ARISTIUN-IAC-042 # Known exception: dev S3 bucket
custom_policies:
- path: ./policies/custom-rules.regoAristiun vs Other Threat-Modeling-as-Code Tools
How Aristiun compares to pytm, TicTaaC, and Threagile across the capabilities that matter for DevSecOps teams.
| Feature | Aristiun | pytm | TicTaaC | Threagile |
|---|---|---|---|---|
| Architecture-aware analysis | — | — | ||
| Zero-config setup | — | — | — | |
| STRIDE + PASTA + LINDDUN | — | — | ||
| CI/CD native integration | — | — | ||
| IaC parsing (Terraform, K8s) | — | — | — | |
| Remediation playbooks | — | — | — | |
| API-first design | — | |||
| Compliance mapping | — | — | — | |
| Drift detection | — | — | — | |
| PR-level gating | — | — |
Continuous Threat Modeling
Threat models shouldn't be point-in-time snapshots. With Aristiun, threat models are living artifacts that stay current automatically.
Auto-Update on Changes
When your architecture changes (new services, modified data flows, updated dependencies), the threat model regenerates automatically. No manual re-analysis needed.
Drift Detection
Aristiun continuously compares the deployed architecture against the declared threat model. When drift is detected, like a new port opened or an unapproved service deployed, you're alerted immediately.
New Threat Notifications
When new CVEs are published or new attack patterns emerge that affect your architecture, Aristiun updates your threat model and notifies the relevant team via Slack, email, or webhook.
Continuous Monitoring Workflow
Frequently Asked Questions
Explore Related Solutions
Automated Threat Modeling
AI-powered STRIDE, PASTA, and LINDDUN analysis for your architecture
Learn moreCode Security
Architecture-aware SAST, DAST, and SCA scanning with remediation playbooks
Learn moreSTRIDE & PASTA Guide
Deep-dive into threat modeling methodologies and frameworks
Learn moreAI Security
Shadow AI discovery and LLM governance for enterprise AI stacks
Learn more