Inferensys

Prompt

Threat Modeling Architecture Prompt Template

A practical prompt playbook for generating structured threat models from system design documents using STRIDE or attack-tree analysis, with prioritized threats, control mapping, and eval checks for production security review workflows.
ML engineer managing model versions on laptop, version history visible, technical Git-like workflow.
PROMPT PLAYBOOK

When to Use This Prompt

Defines the ideal context, user, and prerequisites for generating a structured threat model from a system design, and clarifies when this prompt is not the right tool.

This prompt is for security architects and engineering leads who need to generate a structured threat model from a system design document, architecture diagram description, or data flow narrative. Use it early in the design phase, before implementation, when you have enough detail about components, trust boundaries, data flows, and external dependencies to reason about threats. The prompt produces a STRIDE-categorized threat inventory or an attack-tree analysis with prioritized risks, existing controls, and missing mitigations. It is designed for workflows where a human security reviewer will validate, refine, and sign off on the output before it becomes part of a security review record or compliance artifact.

To use this prompt effectively, you must provide a detailed description of the system's architecture. This includes a list of components (services, data stores, users, external systems), the data flows between them, and explicit trust boundaries. The quality of the output is directly proportional to the specificity of the input. For example, an input stating 'a web app with a database' will yield a generic and less useful threat model. A better input would specify 'a React single-page application authenticating users via OAuth 2.0 with an AWS Cognito User Pool, making API calls through an API Gateway to a set of Lambda functions that read from and write to a DynamoDB table, with all traffic encrypted via TLS 1.3.' This level of detail allows the model to reason about specific threats like token replay, Lambda event injection, or DynamoDB IAM policy misconfigurations. The prompt template uses placeholders like [SYSTEM_DESCRIPTION] and [TRUST_BOUNDARIES] to enforce this structured input.

Do not use this prompt on live production systems where runtime telemetry is available; it is a design-time analysis tool, not a replacement for dynamic testing or penetration testing. It cannot reason about vulnerabilities introduced by specific code implementations, library versions, or runtime configurations. Furthermore, avoid using this prompt for a system that is already fully built and deployed without also pairing it with a review of the as-built state, as design drift is a common source of missed threats. The next step after generating the threat model is to feed the output into a manual review session with the broader engineering team to validate findings, prioritize mitigations, and create actionable security tickets.

PRACTICAL GUARDRAILS

Use Case Fit

Where the Threat Modeling Architecture Prompt works, where it fails, and what you must have in place before running it.

01

Good Fit: Structured Design Docs

Use when: you have a written system design document, architecture diagram description, or data flow narrative. The prompt excels at extracting components, trust boundaries, and data flows from structured prose. Avoid when: the input is a vague whiteboard photo or a single sentence. The model needs explicit component and flow descriptions to produce a credible threat model.

02

Bad Fit: Runtime Threat Detection

Avoid when: you need real-time threat detection from logs, network traffic, or live system telemetry. This prompt performs design-time analysis, not runtime monitoring. Use instead: a Security Operations and Threat Analysis prompt wired to SIEM or observability data. Design review and runtime detection are complementary, not interchangeable.

03

Required Input: Component and Trust Boundary Map

Risk: Without explicit trust boundaries, the model invents plausible but wrong attack paths or misses cross-boundary threats entirely. Guardrail: Always include a description of which components trust which others, where authentication happens, and where data crosses security domains. If the design doc lacks this, run a Data Flow Diagram Security Review prompt first.

04

Required Input: Technology Stack and Protocol Details

Risk: Generic threat models miss implementation-specific threats like JWT algorithm confusion, SQL injection in a specific ORM, or cloud metadata service attacks. Guardrail: Include the technology stack, protocol versions, and deployment environment in the input. The prompt harness should have a [TECH_STACK] placeholder that gates execution.

05

Operational Risk: Over-Confidence on Missing Controls

Risk: The model may assert that a control exists when the design document is silent on the topic, or may miss that a listed control is incorrectly implemented. Guardrail: Every identified threat must be mapped to an explicit control statement from the input document. Threats without documented controls must be flagged as 'control gap' rather than 'mitigated.'

06

Operational Risk: Threat Prioritization Drift

Risk: Without explicit severity criteria, the model may prioritize threats based on common knowledge rather than your specific business impact and exposure. Guardrail: Provide a [RISK_RUBRIC] with your own impact and likelihood definitions. Calibrate with a few known threats from past incidents to verify the model's prioritization aligns with your risk appetite.

PROMPT PLAYBOOK

Copy-Ready Prompt Template

A reusable prompt template for generating structured threat models from system design documents, ready to be adapted with your specific architecture context.

The following prompt template is designed to be copied directly into your AI harness. Every placeholder enclosed in square brackets—such as [SYSTEM_DESIGN], [TRUST_BOUNDARIES], and [OUTPUT_SCHEMA]—must be replaced with your actual system-specific context before sending the prompt to the model. The template assumes you have already gathered architecture diagrams, data flow descriptions, component inventories, and any existing security controls documentation. Do not send incomplete placeholders to the model; the output quality depends entirely on the specificity of the inputs you provide.

code
You are a senior security architect performing a structured threat model on the following system design. Your analysis must be rigorous, evidence-based, and actionable.

## SYSTEM DESIGN
[SYSTEM_DESCRIPTION]

## ARCHITECTURE CONTEXT
- Components: [COMPONENT_LIST]
- Data Flows: [DATA_FLOW_DESCRIPTIONS]
- Trust Boundaries: [TRUST_BOUNDARY_DEFINITIONS]
- External Dependencies: [EXTERNAL_SERVICES_AND_INTEGRATIONS]
- Authentication Mechanisms: [AUTH_MECHANISMS]
- Authorization Model: [AUTHORIZATION_MODEL]
- Data Classification: [DATA_CLASSIFICATION_LEVELS]

## THREAT MODELING METHODOLOGY
Use the [METHODOLOGY] approach. If STRIDE, cover Spoofing, Tampering, Repudiation, Information Disclosure, Denial of Service, and Elevation of Privilege for each trust boundary crossing. If Attack Trees, build trees for each critical asset with AND/OR node decomposition.

## EXISTING CONTROLS
[EXISTING_SECURITY_CONTROLS]

## COMPLIANCE REQUIREMENTS
[COMPLIANCE_STANDARDS]

## OUTPUT SCHEMA
Return a JSON object with this exact structure:
{
  "threat_model": {
    "methodology": "[METHODOLOGY]",
    "scope": "Brief scope statement",
    "assumptions": ["Assumption 1", "Assumption 2"],
    "trust_boundaries_analyzed": [
      {
        "boundary_name": "string",
        "crossing_flows": ["flow1", "flow2"],
        "threats": [
          {
            "threat_id": "TM-001",
            "category": "Spoofing|Tampering|Repudiation|InformationDisclosure|DenialOfService|ElevationOfPrivilege",
            "description": "Clear threat description",
            "affected_component": "component name",
            "attack_vector": "How an attacker would exploit this",
            "likelihood": "High|Medium|Low",
            "impact": "Critical|High|Medium|Low",
            "existing_controls": ["control1"],
            "control_effectiveness": "Adequate|Partial|Missing",
            "missing_mitigations": ["recommended mitigation"],
            "cvss_base_score": "0.0-10.0 or null if not applicable"
          }
        ]
      }
    ],
    "prioritized_risk_register": [
      {
        "rank": 1,
        "threat_id": "TM-001",
        "risk_score": "Critical|High|Medium|Low",
        "rationale": "Why this ranks here"
      }
    ],
    "control_gaps_summary": ["gap1", "gap2"],
    "recommendations": [
      {
        "priority": "P0|P1|P2|P3",
        "action": "Specific remediation action",
        "effort": "Small|Medium|Large",
        "owner_suggestion": "Suggested team or role"
      }
    ]
  }
}

## CONSTRAINTS
- Every threat must reference a specific trust boundary crossing or data flow.
- Do not invent threats for components or flows not described in the system design.
- If a control is listed as existing, evaluate its effectiveness; do not ignore it.
- Mark likelihood as "Low" only when multiple controls make exploitation impractical.
- If compliance requirements are provided, map relevant threats to specific control requirements.
- For any threat rated Critical risk, include a specific P0 recommendation.
- If the system design is incomplete for a category, note it in assumptions rather than guessing.

To adapt this template for your environment, start by replacing [SYSTEM_DESCRIPTION] with a detailed narrative of your architecture—include what the system does, who uses it, and where it runs. Populate [COMPONENT_LIST] with every service, database, queue, gateway, and external integration. Define [TRUST_BOUNDARY_DEFINITIONS] explicitly: a trust boundary is any point where data or control crosses from a higher-trust zone to a lower-trust zone, such as the public internet to your API gateway, or between microservices in different security domains. Choose [METHODOLOGY] based on your needs—STRIDE works well for systems with clear trust boundaries and data flows, while Attack Trees are better when you have well-defined critical assets like a payment processing pipeline or a customer PII store. If you lack existing controls documentation, replace [EXISTING_SECURITY_CONTROLS] with "No controls documented; assume baseline cloud defaults" rather than leaving it empty, so the model knows to flag missing controls rather than assuming they exist.

Before integrating this prompt into a production workflow, validate that every placeholder has been replaced with concrete, non-generic content. A common failure mode is providing vague component names like "auth service" without specifying the protocol, token format, or session behavior—this produces threats that are too generic to act on. Test the prompt first with a known architecture where you can manually verify the threat model output. If the model misses obvious threats, your system description likely lacks the detail the model needs to reason about attack paths. After generation, always have a human security architect review the output before filing findings into a bug tracker or risk register. The model can identify patterns and suggest mitigations, but it cannot replace the contextual judgment of an engineer who understands the business impact of each threat.

IMPLEMENTATION TABLE

Prompt Variables

Inputs the threat modeling prompt needs to work reliably. Validate each before sending to avoid incomplete threat coverage or hallucinated controls.

PlaceholderPurposeExampleValidation Notes

[SYSTEM_DESIGN_DOCUMENT]

Full text of the architecture document, data flow diagram description, or design proposal to analyze

A 12-page design doc covering a new payment processing service with API gateway, auth service, and PostgreSQL backend

Must be non-empty string. Minimum 200 characters. Reject if only a diagram image without text description. Check for presence of component names, data flows, and trust boundaries.

[THREAT_MODEL_METHODOLOGY]

The analysis framework to apply: STRIDE, attack trees, LINDDUN, or a custom taxonomy

STRIDE

Must match one of: STRIDE, ATTACK_TREE, LINDDUN, CUSTOM. If CUSTOM, [CUSTOM_TAXONOMY] must also be provided. Default to STRIDE if null.

[CUSTOM_TAXONOMY]

User-defined threat categories when [THREAT_MODEL_METHODOLOGY] is CUSTOM

["Credential Leak", "Data Exfiltration", "Denial of Wallet"]

Required only if [THREAT_MODEL_METHODOLOGY] is CUSTOM. Must be a non-empty array of strings. Each category must be 3-80 characters. Reject if empty or contains duplicates.

[TRUST_BOUNDARIES]

Explicit list of trust boundaries in the system, or null to let the model infer them

["Internet to API Gateway", "API Gateway to Auth Service", "Auth Service to Database"]

If provided, must be a non-empty array of strings. If null, model will infer boundaries from [SYSTEM_DESIGN_DOCUMENT]. Validate that each boundary references components present in the design document.

[EXISTING_CONTROLS]

Known security controls already in place, to avoid flagging already-mitigated threats

["mTLS between all services", "AWS KMS for encryption at rest", "WAF on API Gateway"]

If provided, must be an array of strings. Can be empty array. Each control should be specific enough to map to a threat category. Avoid vague entries like "good security".

[COMPLIANCE_STANDARDS]

Regulatory or compliance frameworks that threats must be evaluated against

["PCI DSS 4.0", "SOC 2 Type II"]

If provided, must be an array of strings. Can be null. If present, output must include compliance-specific threat mappings. Validate standards are recognizable framework names.

[OUTPUT_SCHEMA]

The expected JSON schema for the threat model output

{"threats": [{"id": "string", "category": "string", "description": "string", "affected_component": "string", "existing_controls": ["string"], "missing_controls": ["string"], "severity": "string", "likelihood": "string", "compliance_impact": ["string"]}]}

Must be a valid JSON Schema object. If null, use default STRIDE output schema. Validate schema is parseable before sending. Reject schemas that lack required threat fields: id, category, description, severity.

[CONFIDENCE_THRESHOLD]

Minimum confidence level for including a threat in the output. Threats below this threshold are omitted or flagged as speculative

0.7

Must be a float between 0.0 and 1.0. Default 0.5 if null. Lower values produce more threats with higher false-positive risk. Higher values may miss edge-case threats. Validate range before sending.

PROMPT PLAYBOOK

Implementation Harness Notes

How to wire the threat modeling prompt into an application or security review workflow with validation, retries, and human approval gates.

Integrating this prompt into a production security review workflow requires treating it as a structured data pipeline, not a chat interface. The prompt expects a system design document as [DESIGN_DOC] and an optional [THREAT_MODEL_METHODOLOGY] (e.g., STRIDE, attack trees, LINDDUN). The output is a structured threat model JSON object containing threats, existing controls, missing mitigations, and a priority score. The harness must validate this output against a strict schema before accepting it, because downstream risk registers and ticketing systems depend on consistent field types and completeness. A thin orchestration layer—whether a Python script, a CI/CD plugin, or a security orchestration platform—should own the lifecycle: fetch the design doc, assemble the prompt, call the model, validate the response, and route the result.

The harness should enforce a validate-or-retry loop. Define a JSON schema that requires threats (array of objects with id, title, category, stride_element, description, existing_controls, missing_mitigations, priority), methodology, coverage_notes, and unmodeled_areas. After the model responds, parse the JSON. If parsing fails, retry with the error message appended to the prompt, up to a maximum of 2 retries. If validation against the schema fails, extract the specific field errors and include them in the retry prompt. Log every attempt—raw prompt, raw response, parse errors, and validation errors—to an audit trail. For high-risk systems (e.g., financial transaction flows, healthcare data pipelines), insert a human approval gate after successful validation: route the structured threat model to a security architect's review queue before it is committed to the risk register. Use a model with strong JSON mode and reasoning capabilities (e.g., Claude 3.5 Sonnet, GPT-4o) and set temperature to 0.1–0.2 to maximize structural consistency without sacrificing threat creativity.

Common failure modes in the harness include: the model producing threats that don't map to the specified methodology, omitting the existing_controls field for threats where controls are absent (it should return an empty array, not null), and hallucinating threats for components not mentioned in the design doc. Mitigate these by adding an eval step that checks threat-to-methodology alignment and design-doc grounding. Run a second LLM call as a judge to score each threat on evidence_in_design_doc (1–5) and methodology_alignment (1–5). Flag threats scoring below 3 for human review. Do not ship threat models directly to Jira or a risk register without this grounding check—an ungrounded threat model erodes trust in the entire security review process.

IMPLEMENTATION TABLE

Expected Output Contract

Defines the exact shape, types, and validation rules for the threat model output. Use this contract to parse the model response, validate it before downstream use, and detect regressions when the prompt changes.

Field or ElementType or FormatRequiredValidation Rule

threat_model_title

string

Must match regex ^[A-Za-z0-9\s-_:]{1,120}$. Reject if empty or generic placeholder like 'Threat Model'.

generated_at

ISO-8601 datetime string

Must parse as valid datetime. Reject if in the future or before [SYSTEM_DESIGN_DATE].

system_boundary_summary

string (1-3 sentences)

Length must be between 20 and 500 characters. Must contain at least one reference to a component from [SYSTEM_DESIGN_DOC].

threats

array of objects

Array must contain at least 1 item. Each item must conform to the threat_object schema below.

threats[].id

string (format: THREAT-XXXX)

Must match regex ^THREAT-\d{4}$. IDs must be unique within the array.

threats[].stride_category

enum: Spoofing, Tampering, Repudiation, Information Disclosure, Denial of Service, Elevation of Privilege

Must be one of the six STRIDE categories. Case-sensitive.

threats[].description

string

Length must be between 30 and 500 characters. Must reference at least one specific component or data flow from [SYSTEM_DESIGN_DOC].

threats[].existing_controls

array of strings

Array must contain at least 0 items. Each string must be between 10 and 200 characters. If empty, the threat is flagged as 'unmitigated'.

threats[].missing_mitigations

array of strings

Array must contain at least 1 item if existing_controls is empty. Each string must be between 10 and 300 characters and start with an action verb.

threats[].severity

enum: Critical, High, Medium, Low, Informational

Must be one of the five severity levels. If severity is Critical or High and existing_controls is empty, trigger a human review flag.

threats[].attack_tree_path

array of strings (ordered steps)

If present, array must contain at least 2 steps. Each step must be between 10 and 200 characters. Steps must form a logical sequence from entry point to impact.

control_coverage_summary

object

Must contain keys: total_threats (integer), mitigated_threats (integer), unmitigated_threats (integer). total_threats must equal mitigated_threats + unmitigated_threats.

review_required

boolean

Must be true if any threat has severity Critical or High with empty existing_controls. Otherwise false. Schema check: type must be boolean, not string.

PRACTICAL GUARDRAILS

Common Failure Modes

Threat modeling prompts fail in predictable ways. These are the most common failure modes when generating structured threat models from system design documents, and how to guard against them before they reach production.

01

Threat Coverage Gaps from Incomplete Design Input

What to watch: The prompt generates threats only for explicitly documented components, missing entire attack surfaces because the design document omitted authentication flows, data stores, or external integrations. The model cannot threat-model what it cannot see. Guardrail: Pre-process design documents with a completeness checklist before threat modeling. Require explicit sections on trust boundaries, data flows, and external dependencies. If sections are missing, flag them for human completion rather than silently generating an incomplete model.

02

Generic Threats Without System-Specific Context

What to watch: The model produces plausible-sounding but generic STRIDE entries that could apply to any system—SQL injection, broken authentication, excessive permissions—without connecting them to the actual architecture described. This creates a false sense of security because the threats look real but miss system-specific risks. Guardrail: Require each threat to cite a specific component, data flow, or trust boundary from the input document. Add an eval check that rejects threats without explicit architectural references. Use few-shot examples showing system-specific threat language.

03

Control Overstatement and Missing Mitigation Gaps

What to watch: The prompt accepts stated controls at face value without questioning their effectiveness, coverage, or implementation status. A design document claiming 'encryption everywhere' may mask missing key rotation, or 'RBAC enforced' may hide role explosion. The output lists controls as adequate when they are not. Guardrail: Add a control-challenge step that asks: 'For each stated control, identify what it does NOT protect against and what implementation gaps could undermine it.' Require the output to distinguish between designed controls and verified controls.

04

STRIDE Category Misclassification

What to watch: The model miscategorizes threats across STRIDE dimensions—labeling an authorization flaw as spoofing, or a denial-of-service risk as information disclosure. Misclassification leads to wrong mitigation strategies and gaps in coverage analysis. Guardrail: Include STRIDE definitions and category-specific examples in the prompt. Add a post-generation validation step that checks each threat's category against its description. Flag threats where the category and described impact are inconsistent for human review.

05

Prioritization Without Business Impact Context

What to watch: The prompt assigns severity ratings based on technical exploitability alone, ignoring business context such as data sensitivity, regulatory exposure, or revenue impact. A medium-severity information disclosure in a HIPAA-covered data store may be catastrophic, while a high-severity DoS on a non-critical service may be acceptable. Guardrail: Require data classification and business impact context as inputs alongside the architecture document. Add prioritization criteria that weight technical severity by data sensitivity and system criticality. Flag threats where severity and business impact appear misaligned.

06

Hallucinated Components and Non-Existent Attack Paths

What to watch: The model invents components, APIs, or data flows not present in the design document, then generates threats against these fabricated elements. This wastes review time and erodes trust in the output. Common with vague design documents where the model fills gaps with plausible but incorrect assumptions. Guardrail: Add an explicit instruction: 'Only threat-model components, data flows, and trust boundaries explicitly described in the input. If information is missing, flag it as an assumption gap rather than inventing details.' Validate generated threats against a component inventory extracted from the input.

IMPLEMENTATION TABLE

Evaluation Rubric

Score each dimension on a 1-5 scale where 5 is production-ready. Use this rubric to test the threat model output before integrating it into a security review workflow.

CriterionPass StandardFailure SignalTest Method

Threat Coverage Completeness

All STRIDE categories addressed for each trust boundary; no missing threat classes

Output skips a STRIDE category or ignores a documented data flow

Automated check: verify each STRIDE label appears at least once per boundary in the output

Control Mapping Accuracy

Every identified threat maps to at least one existing control or explicitly states 'no control exists'

Threat listed without any control reference; orphaned threat without mitigation status

Schema validation: confirm [THREAT_ID] has a non-empty [EXISTING_CONTROLS] array or [MISSING_MITIGATION] flag set to true

Priority Scoring Consistency

Threat severity scores align with CVSS-like dimensions: exploitability, impact, and exposure

Low-impact denial-of-service scored higher than remote code execution; scores contradict documented context

Spot-check: sample 3 threats and verify [SEVERITY_SCORE] matches [EXPLOITABILITY] and [IMPACT] values from the input design doc

Asset Identification Precision

Every threat references a specific asset, component, or data store from the input design document

Vague asset references like 'the system' or 'user data' without mapping to a named component

Grep output for asset names; confirm each [AFFECTED_ASSET] matches a string from the [SYSTEM_DESIGN] input

Mitigation Actionability

Missing mitigations include a concrete control type, implementation owner, and validation test

Mitigation reads 'implement authentication' without specifying protocol, scope, or verification method

Manual review: check that [RECOMMENDED_MITIGATION] contains a control category, a suggested implementation pattern, and a testable acceptance criterion

Trust Boundary Enumeration

Output lists every trust boundary from the input design before assigning threats

Boundaries from the data flow diagram are missing; threats assigned to non-existent boundaries

Diff check: extract all [TRUST_BOUNDARY] values from output and compare to a parsed list of boundaries from [SYSTEM_DESIGN]

False Positive Rate

No threats reported for components or flows that are explicitly out of scope or already fully mitigated with compensating controls noted

Threat reported for a deprecated endpoint marked 'out of scope' in the input; duplicate threats for the same control gap

Human review: flag any threat where [EXISTING_CONTROLS] fully addresses the risk and [RESIDUAL_RISK] is 'none'; confirm out-of-scope exclusions are respected

Output Schema Compliance

Output parses cleanly against the defined [OUTPUT_SCHEMA]; all required fields present and typed correctly

JSON parse failure; missing required fields like [THREAT_ID] or [SEVERITY_SCORE]; string where array expected

Automated schema validation: run output through a JSON Schema validator configured with the expected threat model schema before accepting

ADAPTATION OPTIONS

Adapt This Prompt

How to adapt

Add a strict JSON output schema with fields for threat ID, STRIDE category, affected component, attack path, existing controls, missing mitigations, and severity. Include a validator that checks every threat has a control mapping and every STRIDE category is covered. Add retry logic: if the output fails schema validation, re-prompt with the validation errors appended to [CONSTRAINTS].

Watch for

  • Silent format drift where the model drops required fields under long design docs
  • Threats that reference components not present in the input document
  • Severity inflation when the model lacks calibration data
Prasad Kumkar

About the author

Prasad Kumkar

CEO & MD, Inference Systems

Prasad Kumkar is the CEO & MD of Inference Systems and writes about AI systems architecture, LLM infrastructure, model serving, evaluation, and production deployment. Over 5+ years, he has worked across computer vision models, L5 autonomous vehicle systems, and LLM research, with a focus on taking complex AI ideas into real-world engineering systems.

His work and writing cover AI systems, large language models, AI agents, multimodal systems, autonomous systems, inference optimization, RAG, evaluation, and production AI engineering.