This prompt is designed for security architects and engineering leads who need to generate a structured threat model from a feature specification or design document before a single line of code is written. It takes a feature description, architecture notes, data flow diagrams, and trust boundary definitions as input and produces a threat inventory organized by STRIDE categories, an attack surface enumeration, and prioritized mitigation recommendations. The primary job-to-be-done is shifting security analysis left into the design phase, where the cost of fixing architectural flaws is lowest. Use this prompt during design review gates, security architecture sprints, or as part of a formal shift-left security program that requires documented threat analysis before implementation begins.
Prompt
Threat Modeling Prompt for New Feature Design

When to Use This Prompt
Understand the job-to-be-done, the required inputs, and the operational boundaries for generating a structured threat model from a feature specification.
The prompt requires four concrete inputs to produce a reliable output: a detailed feature specification describing what the system will do, architecture notes covering component interactions and technology choices, data flow diagrams or descriptions showing how data moves between trust boundaries, and explicit trust boundary definitions that mark where privilege levels or network segments change. Without these inputs, the model will hallucinate architecture details or miss entire attack surfaces. The output contract is a structured threat model containing a STRIDE-categorized threat inventory, an attack surface enumeration with entry points and exposure ratings, and prioritized mitigation recommendations mapped to specific threats. Each finding should include a unique identifier, the affected component, the threat scenario, and a severity rationale grounded in the provided architecture context.
Do not use this prompt for runtime incident response, live vulnerability scanning, or compliance audits. Those workflows require different evidence grounding, output contracts, and operational constraints. For incident response, you need prompts that correlate runtime signals with source code and recent changes. For vulnerability scanning, you need prompts that interpret static analysis or dependency scan results against exploitability context. For compliance audits, you need prompts that produce auditor-ready evidence packages with traceable citations to regulatory requirements. This prompt is also not suitable when the feature design is still in flux—wait until the architecture notes and trust boundaries are stable enough to serve as grounding evidence. If the design changes significantly after threat modeling, re-run the prompt with updated inputs rather than attempting to patch the previous output.
Use Case Fit
Where this threat modeling prompt works, where it fails, and what you must provide to get a reliable structured threat inventory.
Good Fit: Structured Design Docs
Use when: you have a feature specification, architecture decision record, or design document with clear components, data flows, and trust boundaries. Guardrail: The prompt relies on explicit design scope; if the doc is vague, the threat model will be vague. Pre-process the input to extract entities and flows before threat enumeration.
Bad Fit: Runtime Exploit Generation
Avoid when: you need penetration test scripts, exploit code, or live vulnerability validation. Guardrail: This prompt produces a threat inventory and mitigation recommendations, not active exploits. Pair with a separate SAST/DAST harness for validation, and add a refusal boundary for exploit-generation requests.
Required Input: Trust Boundary Map
Risk: Without explicit trust boundaries, the model will miss cross-boundary threats like auth bypass, token replay, or tenant isolation failures. Guardrail: Always include a trust boundary diagram or structured description in [DESIGN_CONTEXT]. Validate output completeness by checking that every boundary crossing has at least one associated threat.
Required Input: Data Flow Inventory
Risk: Missing data flows lead to blind spots for injection, leakage, and tampering threats. Guardrail: Provide a structured list of data flows in [DATA_FLOWS] with source, destination, protocol, and data classification. The eval harness should flag any flow without a corresponding threat entry.
Operational Risk: STRIDE Coverage Gaps
Risk: The model may over-index on Spoofing and Tampering while skipping Information Disclosure, Repudiation, Denial of Service, or Elevation of Privilege. Guardrail: Post-process the output with a STRIDE category counter. If any category has zero threats, re-prompt with explicit focus on the missing category and re-validate.
Operational Risk: Mitigation Vagueness
Risk: Mitigations like 'implement proper authentication' are too vague to action. Guardrail: The prompt template must constrain [MITIGATION_FORMAT] to require concrete controls (e.g., 'enforce mTLS between service A and B', 'add row-level security policy on table X'). Validate output with a specificity check that rejects generic phrases.
Copy-Ready Prompt Template
A reusable prompt template with square-bracket placeholders for generating a structured threat model from a feature specification.
The following prompt template is designed to be copied directly into your AI harness, IDE, or orchestration layer. It accepts a feature specification and a set of constraints, and it produces a structured threat model. Every placeholder in square brackets must be replaced with concrete values before execution. Do not leave any placeholder unresolved in production—missing context is the most common cause of vague or incomplete threat models.
textYou are a senior security architect performing a threat modeling review for a new feature. Your analysis must be grounded in the provided feature specification and design documents. Do not invent threats that are not plausible given the described architecture, data flows, and trust boundaries. ## INPUT Feature Specification: [FEATURE_SPECIFICATION] Design Documents (optional): [DESIGN_DOCUMENTS] ## CONSTRAINTS - Risk tolerance level: [RISK_TOLERANCE: low | medium | high] - Deployment environment: [DEPLOYMENT_ENVIRONMENT: cloud | on-premise | hybrid | air-gapped] - Regulatory context: [REGULATORY_CONTEXT: none | GDPR | HIPAA | PCI-DSS | SOC2 | FedRAMP | custom] - Scope boundary: [SCOPE_BOUNDARY: description of what is in and out of scope] ## OUTPUT SCHEMA Return a JSON object with the following structure: { "feature_summary": "One-sentence summary of the feature under review.", "trust_boundaries": [ { "boundary_id": "TB-01", "name": "Short boundary name", "description": "What crosses this boundary and why it matters.", "crossing_data": ["data element 1", "data element 2"], "crossing_direction": "inbound | outbound | bidirectional" } ], "attack_surface": [ { "surface_id": "AS-01", "name": "Short surface name", "entry_point": "API endpoint, UI field, file upload, message queue, etc.", "exposure": "public | authenticated | internal | admin-only", "notes": "Why this surface is relevant to threat analysis." } ], "threat_inventory": [ { "threat_id": "T-01", "stride_category": "Spoofing | Tampering | Repudiation | Information Disclosure | Denial of Service | Elevation of Privilege", "title": "Short threat title", "description": "Detailed description of the threat scenario.", "affected_asset": "What component, data store, or user is impacted.", "precondition": "What must be true for this threat to be exploitable.", "impact": "Confidentiality | Integrity | Availability impact with severity rationale.", "likelihood": "low | medium | high with rationale.", "risk_level": "low | medium | high | critical", "related_boundaries": ["TB-01"], "related_surfaces": ["AS-01"] } ], "mitigations": [ { "mitigation_id": "M-01", "addresses_threats": ["T-01"], "strategy": "eliminate | reduce | transfer | accept", "description": "Concrete mitigation action.", "implementation_effort": "low | medium | high", "verification": "How to test that this mitigation is effective." } ], "completeness_notes": "Any threats or surfaces that could not be fully analyzed due to missing information in the specification.", "review_recommendation": "Proceed | Proceed with Mitigations | Escalate for Manual Review" } ## INSTRUCTIONS 1. Start by identifying trust boundaries from the feature specification and design documents. 2. Enumerate the attack surface by listing every entry point where data or control crosses a trust boundary. 3. For each attack surface element, apply STRIDE to generate plausible threats. 4. For each threat, propose at least one concrete mitigation. 5. If the specification is missing critical details needed for analysis, note them in completeness_notes rather than guessing. 6. If the risk tolerance is low or the regulatory context is high-stakes, recommend Escalate for Manual Review when threats with critical or high risk are identified.
To adapt this template, replace each placeholder with data from your feature intake process. The [FEATURE_SPECIFICATION] should be the full text of the PRD, design doc, or RFC. If no design documents exist, set [DESIGN_DOCUMENTS] to "None provided" and expect the model to flag missing architectural detail in completeness_notes. The [SCOPE_BOUNDARY] is critical for preventing scope creep—be explicit about what components, services, and data stores are in scope. After generating the threat model, always run a completeness check: compare the enumerated attack surfaces against your known system topology and verify that every trust boundary crossing is represented. For high-risk features, route the output to a human security reviewer before accepting mitigations.
Prompt Variables
Required and optional inputs for the threat modeling prompt. Each variable must be populated before execution to ensure reliable, scoped output.
| Placeholder | Purpose | Example | Validation Notes |
|---|---|---|---|
[FEATURE_SPEC] | Complete feature specification or design document text | A markdown PRD describing a new OAuth2 integration for a payment API | Must be non-empty string. Check length > 50 chars. Reject if only a title is provided. |
[ARCHITECTURE_DIAGRAM] | Textual description of system components, data flows, and trust boundaries | User -> API Gateway -> Auth Service -> Database. Payment processor is external. | Optional. If null, prompt will rely on [FEATURE_SPEC] alone. If provided, must include at least one trust boundary marker. |
[DATA_CLASSIFICATION] | Classification level of data handled by the feature | PII, PCI, Internal, Public | Must match enum: PII, PCI, PHI, Internal, Public, Restricted. Reject unknown values. Defaults to Internal if null. |
[DEPLOYMENT_CONTEXT] | Target environment where the feature will run | AWS multi-tenant SaaS, GCP VPC with private endpoints | Must be non-empty string. Should include cloud provider and network topology hints. Reject generic values like 'cloud'. |
[EXISTING_CONTROLS] | List of security controls already in place that the feature inherits | WAF, API Gateway rate limiting, Secrets Manager, mandatory code review | Optional. If provided, must be a list of strings. Each control should be a recognizable security mechanism. Null allowed. |
[THREAT_ACTOR_PROFILE] | Primary threat actor type to prioritize in the model | External attacker with authenticated user access, Malicious insider with developer privileges | Must match enum: ExternalUnauthenticated, ExternalAuthenticated, MaliciousInsider, AccidentalInsider, SupplyChain. Reject unknown values. |
[COMPLIANCE_FRAMEWORKS] | Regulatory or compliance frameworks that apply to the feature | SOC 2, PCI DSS 4.0, GDPR | Optional. If provided, must be a list of recognized framework identifiers. Null allowed. If null, compliance-specific threats are deprioritized. |
[OUTPUT_SCHEMA] | Structured schema the model must use for the threat model output | JSON schema with fields: ThreatID, STRIDECategory, Description, AffectedComponent, Likelihood, Impact, Mitigation | Must be a valid JSON Schema object or a reference to a known schema name. Reject if schema is missing required fields for threat inventory. |
Implementation Harness Notes
How to wire the threat modeling prompt into a secure product development workflow with validation, retries, and human review gates.
This prompt is designed to be called programmatically as part of a feature design review pipeline, not as a one-off chat interaction. The harness should accept a structured feature specification (the [FEATURE_SPEC]) and a design document (the [DESIGN_DOC]) as inputs, assemble the prompt with the correct STRIDE categorization schema, and parse the model's output into a machine-readable threat inventory. Because the output drives security decisions, the harness must validate the response against the expected schema before it is presented to a human reviewer or stored in a threat register.
Start by defining a strict output schema that the model must follow. The prompt already requests STRIDE categories, trust boundaries, attack surface elements, and mitigation recommendations. Your harness should validate that the returned JSON contains all required top-level keys (threats, trust_boundaries, attack_surface, mitigations), that each threat has a non-empty stride_category matching one of the six STRIDE types, and that every identified threat references at least one affected component from the design scope. Use a JSON Schema validator in your application layer—do not rely on the model to self-correct without a validation step. If validation fails, implement a single retry by feeding the validation errors back into the prompt as [PREVIOUS_OUTPUT] and [VALIDATION_ERRORS], with a hard stop after two failed attempts to prevent loops.
Model choice matters here. Use a model with strong reasoning capabilities and a large context window, as the combined feature spec and design doc can be lengthy. For high-sensitivity features, route the prompt to a model deployed in your own VPC or private cloud tenant. Log every request and response, including the validated threat model and any validation failures, to an append-only audit store. This log becomes critical evidence for compliance reviews and post-incident analysis. Do not log the raw feature spec if it contains sensitive business logic; instead, log a content hash for traceability.
The harness must enforce a human review gate before any threat model is considered final. After successful validation, route the output to a security architect or engineering lead for approval. The review interface should highlight threats that scored above a configurable risk threshold, flag any trust boundary that was not explicitly mentioned in the design doc (potential model hallucination), and allow the reviewer to accept, reject, or amend each finding. Only after human sign-off should the threat model be persisted to the threat register and linked to the feature's issue tracker.
Avoid wiring this prompt directly into a CI/CD pipeline without the human review gate. An automated threat model is a starting point for expert analysis, not a replacement for it. The most common production failure mode is scope creep: the model may invent components or data flows not present in the design doc. Your harness should cross-reference every component mentioned in the output against the input design scope and flag any additions for the human reviewer. This scope-anchoring check is the single most important guardrail for keeping the threat model grounded in reality.
Expected Output Contract
Defines the structured threat model output fields, their types, and validation rules to ensure completeness and parseability before the output is accepted by downstream systems or human reviewers.
| Field or Element | Type or Format | Required | Validation Rule |
|---|---|---|---|
threat_id | string (THREAT-XXX) | Must match regex ^THREAT-\d{3}$. Must be unique within the output array. | |
title | string | Must be non-empty, 10-200 characters. Must describe the threat, not the asset. | |
stride_category | enum | Must be exactly one of: Spoofing, Tampering, Repudiation, Information Disclosure, Denial of Service, Elevation of Privilege. | |
affected_asset | string | Must reference a named component, data store, or trust boundary from the [DESIGN_SPEC] input. | |
attack_surface | string | Must describe the specific interface, API, or input vector. Cannot be a generic category like 'network'. | |
severity | enum | Must be one of: Critical, High, Medium, Low, Informational. Must align with the described impact. | |
cvss_vector | string (CVSS v3.1) | If present, must be a valid CVSS v3.1 vector string starting with CVSS:3.1/. Null allowed if scoring is deferred. | |
mitigation | string | Must be a concrete, actionable recommendation. Cannot be a generic statement like 'apply secure coding practices'. |
Common Failure Modes
Threat modeling prompts fail in predictable ways. These cards cover the most common failure modes when generating threat models from feature specifications and how to guard against them.
Incomplete Attack Surface Enumeration
What to watch: The model misses entire trust boundaries, API endpoints, or data flows because the design document is ambiguous or the prompt doesn't enforce exhaustive enumeration. The threat model looks plausible but omits critical entry points. Guardrail: Require the prompt to output a structured attack surface inventory before generating threats. Add a completeness check that cross-references every documented input, output, and data store against the enumerated surface. Flag gaps for human review.
STRIDE Category Collapse
What to watch: The model over-assigns threats to one or two STRIDE categories (usually Spoofing and Tampering) while ignoring Information Disclosure, Denial of Service, Elevation of Privilege, and Repudiation. This produces a lopsided model that misses whole classes of risk. Guardrail: Add a post-generation validation step that counts threats per STRIDE category. If any category has zero threats, re-prompt with explicit focus on the missing category using the original design context.
Generic Threats Without Code-Level Context
What to watch: The model produces vague threats like 'ensure input validation' or 'use strong authentication' without referencing specific functions, API routes, or data structures from the feature spec. The output reads like a textbook, not an actionable review. Guardrail: Require each threat to cite a specific component, endpoint, or data flow from the input design document. Add a grounding check that verifies each threat references at least one concrete element from the source material.
Mitigation Recommendations Without Feasibility Context
What to watch: The model suggests mitigations that are technically correct but impractical for the team's stack, timeline, or architecture—like recommending a full zero-trust mesh for a monolith migration. Guardrail: Include architectural constraints and technology stack details in the prompt input. Add a constraint-awareness check that flags mitigations incompatible with the stated stack. Require mitigations to include implementation complexity notes.
Trust Boundary Misidentification
What to watch: The model conflates internal service-to-service communication with external user-facing boundaries, or treats all data stores as equally trusted. This leads to over-investment in low-risk areas and under-investment at real trust boundaries. Guardrail: Require the prompt to output an explicit trust boundary diagram in structured form before threat generation. Add a review step that validates each boundary against the design document's deployment architecture and network topology.
Scope Creep Into Out-of-Scope Systems
What to watch: The model generates threats for upstream services, third-party dependencies, or infrastructure components that are explicitly out of scope for the review. This wastes review time and dilutes focus on the feature under analysis. Guardrail: Define explicit scope boundaries in the prompt with a list of in-scope and out-of-scope components. Add a scope compliance check that filters threats to only those touching in-scope elements. Flag out-of-scope findings separately as external dependencies.
Evaluation Rubric
Criteria for evaluating the quality, completeness, and actionability of a threat model generated from a feature specification. Use this rubric to gate the output before it reaches a security reviewer or is stored as a decision record.
| Criterion | Pass Standard | Failure Signal | Test Method |
|---|---|---|---|
STRIDE Coverage | Every STRIDE category (Spoofing, Tampering, Repudiation, Information Disclosure, Denial of Service, Elevation of Privilege) is addressed with at least one threat or an explicit N/A justification. | One or more STRIDE categories are missing without justification. | Parse the output for STRIDE category labels. Assert count of unique categories equals 6 or missing categories have a non-empty N/A rationale. |
Trust Boundary Enumeration | All trust boundaries implied by the [FEATURE_SPEC] are explicitly listed, including user-to-service, service-to-service, and service-to-data boundaries. | A trust boundary described in the feature spec (e.g., a new third-party API call) is absent from the threat model. | Diff the boundary list against a manual checklist derived from the spec. Flag any spec boundary not found in the output. |
Threat-to-Asset Mapping | Each identified threat is linked to at least one specific asset or component from the [DESIGN_DOC]. | A threat is stated generically (e.g., 'data could be leaked') without naming the affected data store, endpoint, or component. | For each threat entry, check that the associated asset field matches an entity name from the design document. Fail if null or generic. |
Attack Surface Completeness | The attack surface section enumerates entry points (API endpoints, user inputs, file uploads, event triggers) described in the feature spec. | An input vector defined in the spec (e.g., a new webhook receiver) is omitted from the attack surface list. | Extract the attack surface list. Cross-reference with a pre-parsed list of inputs from the spec. Flag missing entries. |
Mitigation Actionability | Every high or critical severity threat includes a concrete, specific mitigation recommendation, not a generic statement like 'use encryption'. | A high-severity threat has a mitigation that is a vague best practice (e.g., 'follow secure coding guidelines') without a code-level or configuration-level suggestion. | For threats with severity >= High, check that the mitigation field contains a specific control (e.g., 'validate JWT audience claim at the API gateway') and is longer than 50 characters. |
Data Flow Diagram Consistency | The described data flows match the sequence of interactions in the [DESIGN_DOC] without introducing phantom components. | The threat model describes a data flow that includes a component (e.g., a cache layer) not present in the design document. | Extract component names from the data flow section. Assert that each is a substring match or synonym of a component in the design document's architecture section. |
Severity Justification | Every threat includes a severity rating with a one-sentence justification referencing impact and likelihood in the context of the feature. | A threat is rated Critical with no justification, or the justification is a restatement of the threat title. | For each threat, assert the severity justification field is non-empty and contains at least one impact keyword (e.g., 'data loss', 'downtime', 'breach') and one likelihood keyword (e.g., 'easily exploitable', 'requires internal access'). |
Out-of-Scope Acknowledgment | The output explicitly lists threat categories or system areas considered out of scope, matching any [CONSTRAINTS] provided. | The output includes threats for infrastructure layers (e.g., physical datacenter security) that were marked out of scope in the prompt constraints. | Check for an 'Out of Scope' section. If [CONSTRAINTS] specifies exclusions, assert that no threat is categorized under an excluded domain. |
Enabling Efficiency, Speed & Accuracy
Intelligent Analysis, Decision & Execution
We build AI systems for teams that need search across company data, workflow automation across tools, or AI features inside products and internal software.
Talk to Us
Search across company data
Give teams answers from docs, tickets, runbooks, and product data with sources and permissions.
Useful when people spend too long searching or get different answers from different systems.

Automate internal workflows
Use AI to route work, draft outputs, trigger actions, and keep approvals and logs in place.
Useful when repetitive work moves across multiple tools and teams.

Add AI to products and internal tools
Build assistants, guided actions, or decision support into the software your team or customers already use.
Useful when AI needs to be part of the product, not a separate tool.
Adapt This Prompt
How to adapt
Use the base prompt with a single feature spec as [FEATURE_DESIGN_DOC]. Skip the completeness validator and accept raw STRIDE output. Replace [DESIGN_SCOPE] with a simple bullet list of components in scope. Drop the trust boundary diagram requirement and ask for a plain-text table instead.
Watch for
- Missing threat categories when the spec is sparse
- Overly generic mitigations like "use encryption" without context
- Model inventing components not in the spec
- No distinction between external and internal trust boundaries

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.
Partnered with leading AI, data, and software stack.
How We Work
Custom AI workflows for your Business
One-fit-all AI don't work for modern businesses. At Inferensys, we aim to understand your business & custom requirements; which we use to define most efficient agentic workflows, the data, and the tools for your business.
01
Review the use case
We understand the task, the users, and where AI can actually help.
Read more02
Pick the right approach
We define what needs search, automation, or product integration.
Read more03
Build the first useful version
We implement the part that proves the value first.
Read more04
Improve from there
We add the checks and visibility needed to keep it useful.
Read moreThe first call is a practical review of your use case and the right next step.
Talk to Us