This prompt is designed for security architects and domain engineers who need to audit authorization boundaries across aggregates and bounded contexts before code ships. It takes a documented domain model description—including aggregates, contexts, and actor definitions—and produces a structured security audit identifying missing access controls, data leakage risks, and trust boundary violations. The primary job-to-be-done is to shift security review left into the design phase, catching authorization flaws when they are cheap to fix rather than after implementation.
Prompt
Domain Model Security Boundary Audit Prompt

When to Use This Prompt
Defines the ideal scenario, required inputs, and critical limitations for the Domain Model Security Boundary Audit Prompt.
Use this prompt during design review sessions, threat modeling workshops, or as a pre-implementation gate before committing to aggregate and service boundaries. The prompt assumes you have a documented domain model with explicit aggregate roots, bounded context definitions, and actor or role descriptions. If your model is purely verbal, sketched on a whiteboard without detail, or missing actor definitions, the audit will produce low-confidence findings that require extensive human verification. The more precise your input, the more actionable the output.
Do not use this prompt as a replacement for penetration testing, runtime security scanning, or production access control audits. It operates at the design level and cannot detect implementation bugs, misconfigured identity providers, or runtime injection vulnerabilities. Additionally, this prompt is not suitable for systems without a domain-driven design foundation—if your architecture lacks explicit aggregate boundaries or context mapping, the security boundary analysis will be speculative at best. Always pair the output with human security review before accepting findings as authoritative.
Use Case Fit
Where the Domain Model Security Boundary Audit Prompt delivers reliable results and where it creates false confidence.
Good Fit: Pre-Implementation Design Review
Use when: security architects are reviewing aggregate designs before code is written. The prompt excels at identifying missing authorization checks, trust boundary violations, and data leakage risks in static design documents. Guardrail: Provide complete aggregate definitions with field-level sensitivity annotations. Without them, the audit produces generic warnings instead of actionable findings.
Bad Fit: Runtime Authorization Debugging
Avoid when: you need to debug why a specific request was denied in production. This prompt analyzes design artifacts, not runtime logs or access control policies. Guardrail: Use observability and trace analysis prompts for runtime debugging. Reserve this prompt for design-time boundary review before implementation.
Required Input: Aggregate Definitions with Sensitivity Labels
What to watch: the prompt cannot infer which fields contain PII, financial data, or regulated information from aggregate names alone. Without explicit sensitivity annotations, the audit misses critical data leakage risks. Guardrail: Provide a structured input with aggregate name, fields, sensitivity classification per field, and cross-aggregate reference paths.
Operational Risk: False Sense of Security
What to watch: a clean audit report can create overconfidence. The prompt identifies design-level authorization gaps but cannot verify that implementation matches the design or that infrastructure-level controls are correctly configured. Guardrail: Always follow the prompt audit with implementation review, penetration testing, and runtime policy validation. Treat the output as a design checklist, not a compliance certificate.
Boundary Condition: Implicit Trust Assumptions
What to watch: the prompt may miss authorization gaps when trust relationships between contexts are documented as assumptions rather than explicit rules. Teams often write 'Context A trusts Context B' without specifying what that trust permits. Guardrail: Require explicit trust contracts in the input. If a trust relationship lacks concrete permissions, flag it as an unresolved finding before running the audit.
Scale Limit: Large Domain Models
What to watch: auditing more than 8-10 aggregates in a single prompt run produces shallow analysis. The model skips edge cases and misses cross-aggregate leakage patterns when context windows are overloaded. Guardrail: Partition large domain models by bounded context. Run separate audits per context, then run a cross-context synthesis pass to catch boundary-spanning risks.
Copy-Ready Prompt Template
A reusable prompt template with square-bracket placeholders for auditing authorization boundaries, trust zones, and data leakage risks across a domain model.
The prompt below is designed to be copied directly into your AI harness. Every placeholder in square brackets must be replaced with concrete artifacts from your domain model before execution. This template assumes you have already prepared a domain model representation (aggregates, entities, value objects, and their relationships), a set of actor roles with intended access patterns, and a list of sensitive data classifications. The prompt instructs the model to act as a security architect performing a structured audit, not as a general-purpose assistant offering vague advice.
textYou are a security architect reviewing a domain model for authorization boundary violations, data leakage risks, and trust boundary misconfigurations. ## DOMAIN MODEL [DOMAIN_MODEL] ## ACTOR ROLES AND INTENDED ACCESS [ACTOR_ROLES_AND_ACCESS] ## SENSITIVE DATA CLASSIFICATIONS [SENSITIVE_DATA_CLASSIFICATIONS] ## OUTPUT SCHEMA Return a JSON object with the following structure: { "audit_summary": { "total_findings": <integer>, "critical_count": <integer>, "high_count": <integer>, "medium_count": <integer>, "low_count": <integer> }, "findings": [ { "id": "SEC-<4-digit-increment>", "severity": "critical|high|medium|low", "category": "missing_access_control|data_leakage|trust_boundary_violation|privilege_escalation|insecure_default|other", "affected_aggregates": ["<aggregate_name>"], "description": "<clear description of the finding>", "threat_scenario": "<how an attacker or unauthorized actor could exploit this>", "violated_principle": "<least_privilege|defense_in_depth|fail_secure|separation_of_duty|other>", "remediation": "<specific design change recommendation>", "effort_estimate": "small|medium|large" } ], "trust_boundary_map": { "boundaries": [ { "name": "<boundary_name>", "between": ["<context_or_aggregate>", "<context_or_aggregate>"], "current_protection": "<description>", "gaps": ["<gap_description>"] } ] }, "data_flow_risks": [ { "flow": "<source> -> <destination>", "data_classification": "<classification>", "risk": "<description>", "current_controls": "<description>", "recommendation": "<description>" } ] } ## CONSTRAINTS - Only report findings supported by evidence in the provided domain model. - Do not invent aggregates, roles, or data flows not present in the input. - If a finding is speculative, mark it as "low" severity and note the assumption. - For each finding, provide a concrete threat scenario, not a generic security platitude. - If no findings exist for a category, return an empty array for that field. - Prefer specific remediation steps over vague guidance like "add access controls." ## RISK_LEVEL [RISK_LEVEL] ## EXAMPLES [EXAMPLES]
After copying the template, replace [DOMAIN_MODEL] with a structured representation of your aggregates, entities, and their relationships. This can be a JSON schema, a text description of bounded contexts and aggregate roots, or a diagram description. Replace [ACTOR_ROLES_AND_ACCESS] with a mapping of user roles, service accounts, or external systems to their intended read/write access on each aggregate. Replace [SENSITIVE_DATA_CLASSIFICATIONS] with your organization's data classification taxonomy (e.g., PII, PCI, PHI, confidential, internal-only). The [RISK_LEVEL] placeholder should be set to the system's risk tolerance (e.g., "high" for regulated systems, "medium" for internal tools). The [EXAMPLES] placeholder should contain one or two example findings that demonstrate the expected depth and specificity. Do not skip this step—examples are the most reliable way to calibrate output quality. Before deploying this prompt into a production pipeline, validate the output against the JSON schema, run at least three known-domain test cases where you already know the expected findings, and require human review for any finding marked "critical" or "high" severity.
Prompt Variables
Required inputs for the Domain Model Security Boundary Audit Prompt. Each placeholder must be populated with concrete, source-grounded data before execution. Missing or vague inputs will produce unreliable audit results.
| Placeholder | Purpose | Example | Validation Notes |
|---|---|---|---|
[DOMAIN_MODEL_DOCUMENTATION] | Full text of the domain model, including aggregate definitions, entity relationships, and business rules | Aggregate: Order (root), OrderLine (entity). Invariant: Order total must equal sum of OrderLine totals. Context: Sales. | Must be non-empty. Parse check: verify document contains at least one aggregate definition with explicit invariants. Reject if only diagrams without text. |
[AUTHORIZATION_POLICY] | Current authorization rules, role definitions, and permission mappings for the system | Role: Customer. Permission: read own orders. Role: Admin. Permission: read all orders, update order status. | Must be non-empty. Schema check: confirm roles map to at least one permission. Null allowed if no formal policy exists, but output must flag this as a critical finding. |
[SYSTEM_ARCHITECTURE_CONTEXT] | Description of service boundaries, API gateways, and data flow between components | Orders API (public), Payment Service (internal), Customer DB (private). Data flow: Orders API calls Payment Service via gRPC on order submission. | Must be non-empty. Parse check: verify at least one service boundary and one data flow path are described. Reject if only component names without interaction paths. |
[TRUST_BOUNDARY_DEFINITIONS] | Explicit definition of trust zones, network segments, and authentication boundaries | Zone A: Public internet (untrusted). Zone B: API gateway (semi-trusted). Zone C: Internal services (trusted). Auth boundary at API gateway via OAuth2. | Must be non-empty. Schema check: confirm at least two distinct trust zones with explicit boundary rules. If null, output must flag missing trust definitions as a critical finding. |
[DATA_CLASSIFICATION_LABELS] | Classification levels for data handled by each aggregate and entity | Order.customerId: PII (Confidential). Order.total: Internal. Payment.token: Restricted (PCI). | Must be non-empty. Parse check: verify at least one entity field is mapped to a classification label. Reject if labels are present but no fields are assigned. |
[EXISTING_ACCESS_CONTROL_RULES] | Implemented access control rules, middleware configurations, or policy-as-code definitions | Middleware: authz.check('order:read', request.user). Policy: deny by default, allow explicit grants. | Must be non-empty. Schema check: confirm at least one concrete rule or policy statement. Null allowed only if system has no access controls, which must be flagged as critical. |
[REGULATORY_REQUIREMENTS] | Applicable regulatory frameworks and specific compliance obligations for the domain | GDPR Article 15 (right of access), PCI DSS Requirement 7 (restrict access to cardholder data by business need-to-know). | Null allowed. If provided, parse check: verify each requirement includes a specific article or control ID. If null, output must note that regulatory scope was not provided and limit claims accordingly. |
Implementation Harness Notes
How to wire the Domain Model Security Boundary Audit Prompt into an application or review workflow.
This prompt is designed for a human-in-the-loop security review workflow, not for autonomous enforcement. The model produces a structured audit report that a security architect or senior engineer must review, challenge, and sign off on before any findings become action items. Wire the prompt into a review pipeline that captures the model's output alongside the source artifacts (domain model diagrams, aggregate definitions, authorization policies) so that every finding is traceable to evidence. The output schema includes a finding_id and evidence_reference field for each issue, which your application should use to link findings back to specific aggregate boundaries, API contracts, or policy documents.
Validation and retry logic: Parse the model's JSON output immediately after generation. Validate that every finding includes a non-empty finding_id, severity (one of CRITICAL, HIGH, MEDIUM, LOW), affected_aggregate, risk_description, and evidence_reference. If the output fails schema validation, retry once with the same prompt plus the validation error message appended as a [VALIDATION_ERROR] constraint. If the second attempt also fails, flag the review session for manual completion and log the raw output for debugging. Do not silently accept malformed audit reports. Model choice: Use a model with strong reasoning capabilities (GPT-4o, Claude 3.5 Sonnet, or equivalent) because boundary analysis requires tracing relationships across multiple aggregates and detecting implicit trust assumptions. Smaller or faster models frequently miss indirect data leakage paths and produce false negatives on MEDIUM and LOW severity findings.
Logging and audit trail: Store the full prompt, model response, validation result, and human reviewer's disposition (accepted, rejected, modified) for every audit run. This creates an evidence trail for compliance reviews and lets you measure the prompt's precision and recall over time. If your organization requires SOC 2, ISO 27001, or similar evidence, the audit trail must include the reviewer's identity, timestamp, and any findings they downgraded or dismissed with rationale. Tool integration: If your domain model lives in a structured format (e.g., OpenAPI specs, protobuf definitions, or architecture decision records in a git repository), use retrieval-augmented generation (RAG) to pull the relevant aggregate definitions and authorization policies into the [DOMAIN_MODEL_CONTEXT] placeholder rather than asking the reviewer to paste them manually. This reduces copy-paste errors and ensures the model audits the actual source of truth. When to escalate: If the model reports a CRITICAL finding, your workflow should automatically create a security review ticket and notify the security team, not wait for the next scheduled review cycle. For HIGH findings, require explicit human approval before closing. For MEDIUM and LOW, allow the reviewer to accept or dismiss with a required comment.
What to avoid: Do not use this prompt as a replacement for penetration testing, threat modeling sessions, or manual code review. The model cannot discover runtime authorization bugs, misconfigured IAM policies, or injection vulnerabilities that exist only in implementation. It audits the design of security boundaries, not their implementation. If your team treats the model's output as a complete security assessment, you will miss implementation-level vulnerabilities. Always pair this prompt with static analysis of authorization code, dynamic testing of access controls, and periodic manual threat modeling. The prompt is a force multiplier for experienced reviewers, not a substitute for security expertise.
Expected Output Contract
Fields, format, and validation rules for the Domain Model Security Boundary Audit output. Use this contract to parse and validate the model response before surfacing findings.
| Field or Element | Type or Format | Required | Validation Rule |
|---|---|---|---|
audit_id | string (UUID v4) | Must match regex ^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$ | |
target_context | string | Must be non-empty and match one of the bounded context names provided in [CONTEXT_NAMES] | |
findings | array of objects | Must be a JSON array with at least 1 item; empty array triggers retry with lower confidence threshold | |
findings[].id | string (FIND-XXX) | Must match regex ^FIND-\d{3}$ and be unique within the findings array | |
findings[].severity | enum: CRITICAL, HIGH, MEDIUM, LOW, INFO | Must be one of the listed enum values; CRITICAL findings require human review flag set to true | |
findings[].aggregate_root | string | Must be non-empty and match an aggregate root name from [AGGREGATE_ROOTS] | |
findings[].vulnerability_type | enum: MISSING_ACCESS_CONTROL, DATA_LEAKAGE, TRUST_BOUNDARY_VIOLATION, INSUFFICIENT_VALIDATION, OVERPRIVILEGED_QUERY, CROSS_CONTEXT_LEAK, UNPROTECTED_EVENT | Must be one of the listed enum values | |
findings[].description | string | Must be between 50 and 500 characters; must reference a specific field, method, or relationship from [DOMAIN_MODEL] |
Common Failure Modes
What breaks first when auditing domain model security boundaries and how to guard against it.
Authorization Logic Leaks Across Aggregates
What to watch: The model assumes authorization rules from one aggregate apply to another, or recommends sharing authorization logic across contexts without an Anti-Corruption Layer. This creates implicit trust boundaries that fail silently when contexts evolve independently. Guardrail: Require the prompt to enumerate authorization rules per aggregate and flag any cross-aggregate assumptions. Add an eval check that counts distinct authorization contexts and fails if any aggregate inherits rules without explicit mapping.
Missing Write-Once vs Read-All Access Separation
What to watch: The audit output treats all access patterns uniformly, failing to distinguish between commands that mutate state and queries that read it. This masks privilege escalation risks where a role granted read access to a projection also gains implicit write access to the underlying aggregate. Guardrail: Include a constraint in the prompt template requiring separate analysis of command authorization and query authorization per aggregate. Validate the output contains distinct sections for mutation boundaries and read boundaries.
Trust Boundary Collapse in Event Handlers
What to watch: The audit overlooks authorization gaps in domain event consumers. A handler in Context B that reacts to events from Context A may execute with elevated privileges or bypass Context B's own authorization checks because the event is treated as trusted input. Guardrail: Add a prompt instruction to trace every event handler's authorization context back to the originating principal. Test with a scenario where an event crosses trust boundaries and verify the output flags the handler's privilege level.
Data Leakage Through Over-Fetched Projections
What to watch: The audit recommends or accepts read models that include fields from the aggregate not required by the consumer, creating data leakage vectors. A projection built for one use case may expose PII or sensitive fields when reused by another service. Guardrail: Require field-level justification in the output for every projected attribute. Add a validation step that compares projected fields against the consumer's stated needs and flags any field without an explicit purpose.
Implicit Trust in Upstream Context Data
What to watch: The audit assumes data received from an upstream bounded context is already authorized and sanitized. This misses scenarios where the upstream context has different security classifications, a compromised integration, or a bug that leaks data across its own boundaries. Guardrail: Instruct the prompt to treat every cross-context data flow as untrusted by default. Validate the output includes re-authorization checks at context entry points and fails if any upstream data is accepted without explicit validation.
Role-to-Aggregate Mapping Gaps
What to watch: The audit identifies authorization rules but fails to map them to concrete roles, personas, or identity claims. This produces a security model that looks complete on paper but cannot be enforced because no actual identity system produces the required claims. Guardrail: Add an output schema requirement that every authorization rule must reference a verifiable identity claim or role. Test by checking that zero authorization statements lack a corresponding principal identifier.
Evaluation Rubric
Criteria for testing the Domain Model Security Boundary Audit Prompt before shipping. Each row defines a pass standard, a failure signal, and a concrete test method.
| Criterion | Pass Standard | Failure Signal | Test Method |
|---|---|---|---|
Aggregate Coverage | Every aggregate in [DOMAIN_MODEL_SPEC] is mentioned in the audit output | One or more aggregates are absent from the audit | Parse output for aggregate names; diff against input spec list |
Authorization Rule Identification | Each aggregate has at least one explicit authorization rule or a documented 'no rule found' flag | An aggregate has neither a rule nor a null flag | Schema check: for each aggregate, field [authorization_rules] is non-empty or [missing_rule] is true |
Trust Boundary Mapping | Output includes a trust boundary map with at least one boundary and the aggregates assigned to it | Trust boundary map is missing, empty, or assigns aggregates to no boundary | Parse [trust_boundaries] array; assert length > 0; assert each boundary has a non-empty [aggregates] list |
Data Leakage Risk Identification | At least one data leakage risk is identified per trust boundary crossing | A boundary crossing has zero associated risks | For each pair of boundaries with a defined crossing, assert [data_leakage_risks] array is non-empty |
Missing Access Control Flagging | Output flags at least one missing access control if [AUTH_POLICY_DOC] is incomplete | Audit claims all controls are present when known gaps exist in the input policy | Ground-truth comparison: inject a known missing control in test fixture; assert [missing_controls] array includes it |
Evidence Grounding | Every finding references a specific section or line from [DOMAIN_MODEL_SPEC] or [AUTH_POLICY_DOC] | A finding has a null, empty, or hallucinated [source_reference] | Regex check on [source_reference] field for each finding; assert matches document section pattern |
Output Schema Validity | Output parses cleanly against the defined [OUTPUT_SCHEMA] with no missing required fields | JSON parse fails or required fields are null | Automated schema validation run against output; retry once on failure |
False Positive Rate | No more than 1 false positive risk flagged per 5 aggregates in a clean test fixture | Audit flags 2 or more risks that are not present in a known-clean model | Run against a reviewed secure model fixture; count flagged risks; assert count <= 1 per 5 aggregates |
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 aggregate or bounded context document. Remove strict output schema requirements and accept a free-text security boundary report. Focus on surfacing obvious trust boundary violations and missing access controls without requiring formal evidence citations.
Simplify the prompt to:
codeReview the following domain model for security boundary issues. Identify where authorization checks are missing, data leaks across trust boundaries, and where aggregates expose internal state they shouldn't. Domain model: [DOMAIN_MODEL_DOCUMENT]
Watch for
- Overly broad findings without specific line or rule references
- Model hallucinating access control patterns that don't exist in the document
- Missing distinction between authentication and authorization gaps
- No severity ranking, making it hard to prioritize fixes

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