This prompt is built for a security architect or lead engineer who has a session management design document, an architecture diagram description, or a configuration specification and needs a rigorous, lifecycle-based threat review. The job-to-be-done is not a runtime penetration test or a code-level vulnerability scan; it is a design-level analysis that identifies missing controls, architectural weaknesses, and threat vectors across the entire session lifecycle: creation, storage, transmission, timeout, refresh, and termination. The ideal user brings a concrete design artifact and wants a structured output that maps specific threats—such as session fixation, hijacking, cross-device token replay, and logout CSRF—to the controls that are present, weak, or absent.
Prompt
Session Management Security Review Prompt

When to Use This Prompt
Use this prompt to perform a structured threat analysis of a session management design before any code is written.
To use this prompt effectively, you must supply a detailed [DESIGN_SPEC] that describes the proposed session mechanism. This could include token types (opaque, JWT, reference), storage locations (cookies, local storage, secure enclaves), transmission channels, cookie attributes (Secure, HttpOnly, SameSite), timeout policies (idle, absolute), refresh token flows, and termination procedures. The prompt is not suitable for reviewing a live system's configuration or for generating a penetration test plan. It also should not be used in isolation; it belongs in a security review gate alongside an authentication flow review and an authorization model audit. The output is a structured threat analysis, not a compliance checklist, and it assumes the reviewer will apply their own judgment to the findings.
Before running the prompt, ensure the design spec is complete enough to reason about each lifecycle stage. A vague or incomplete spec will produce a vague analysis. After receiving the output, map each identified threat to a specific design change or acceptance of risk. Do not treat the AI's output as a final sign-off; it is a structured starting point for a human-led security review. The next step is to take the threat list and missing controls into a design discussion with the engineering team, updating the session management design before implementation begins.
Use Case Fit
Where this prompt works, where it fails, and the operational preconditions required before you run it in a production review pipeline.
Good Fit: Design Document Review
Use when: You have a complete session management design document describing token generation, storage, refresh, and termination. Guardrail: The prompt requires explicit design details; vague proposals produce vague threats. Feed it structured architecture decision records for the best signal.
Bad Fit: Runtime Incident Triage
Avoid when: You are investigating an active session hijacking incident and need real-time log analysis. Guardrail: This prompt analyzes design intent, not runtime behavior. Pair it with a log analysis prompt for incident response, and never substitute design review for forensic investigation.
Required Inputs
Risk: Running the prompt without session lifecycle details produces generic OWASP top-10 lists instead of actionable findings. Guardrail: Require at minimum: token type, storage mechanism, transmission channel, timeout policy, refresh flow, and revocation strategy. Missing inputs should block the review, not trigger guesswork.
Operational Risk: False Confidence
Risk: A clean review output can create a false sense of security if the design document doesn't match the implementation. Guardrail: Always follow design review with implementation verification. The prompt should include a disclaimer that it reviews documented intent, not deployed reality.
Precondition: Reviewer Expertise
Risk: The prompt surfaces threats but cannot validate whether the reviewer understands token binding or rotation trade-offs. Guardrail: Require a security engineer or architect to interpret findings. The prompt is an accelerator, not a replacement for domain judgment. Escalate findings tagged CRITICAL to human review.
Boundary: Protocol-Specific Depth
Risk: The prompt may miss protocol-specific vulnerabilities in OAuth 2.0, SAML, or custom token formats if the design document uses non-standard terminology. Guardrail: For protocol-heavy designs, chain this prompt with a protocol-specific review prompt (e.g., OAuth flow review) rather than relying on a single session management pass.
Copy-Ready Prompt Template
A copy-ready prompt template for conducting a structured session management security review against a provided system design.
The following prompt template is designed to be pasted directly into your AI workflow. It instructs the model to act as a security architect and perform a structured threat analysis of a session management design. The template uses square-bracket placeholders for all variable inputs, such as the design document, risk tolerance, and specific compliance standards. You must replace these placeholders with your concrete details before execution. The prompt is self-contained and forces the model to produce a structured output, making it suitable for direct integration into a CI/CD pipeline, a design review checklist, or an architecture decision record (ADR) workflow.
markdownYou are a principal security architect reviewing a system's session management design. Your task is to produce a structured threat analysis covering the entire session lifecycle: creation, storage, transmission, refresh, and termination. **DESIGN DOCUMENT:** [DESIGN_DOCUMENT] **REVIEW CONTEXT:** - Risk Tolerance: [RISK_TOLERANCE, e.g., "moderate", "highly sensitive financial data"] - Compliance Standards: [COMPLIANCE_STANDARDS, e.g., "OWASP ASVS V3", "PCI DSS", "NIST SP 800-63B"] - Client Types: [CLIENT_TYPES, e.g., "SPA", "mobile native", "server-rendered web app"] **OUTPUT SCHEMA:** Return a valid JSON object with the following structure. Do not include any text outside the JSON object. { "summary": "A one-paragraph executive summary of the session management posture.", "lifecycle_analysis": [ { "phase": "One of: creation, storage, transmission, refresh, termination", "finding": "Description of a specific threat, misconfiguration, or missing control.", "severity": "critical | high | medium | low", "cve_or_owasp_ref": "Relevant CWE or OWASP ASVS reference, e.g., CWE-384.", "remediation": "A specific, actionable recommendation." } ], "cookie_attribute_audit": { "session_cookie_name": "[Inferred or 'unknown']", "secure_flag": "set | missing | unknown", "httponly_flag": "set | missing | unknown", "samesite_attribute": "Strict | Lax | None | missing | unknown", "path_attribute": "[value or 'unknown']", "domain_attribute": "[value or 'unknown']", "expires_maxage": "[value or 'unknown']" }, "token_binding_assessment": "An assessment of whether token binding (e.g., mTLS, DPoP) is used to prevent token replay and hijacking. State 'not applicable' if no evidence is found.", "cross_device_risk": "An analysis of risks related to session transfer, QR-code login, or multi-device session continuity.", "overall_risk_rating": "critical | high | medium | low", "top_3_actions": ["Action 1", "Action 2", "Action 3"] } **CONSTRAINTS:** - Base every finding on evidence in the provided design document. If a detail is not specified, state it as 'unknown' and explain the implied risk. - Do not hallucinate features or controls not present in the design. - Prioritize findings that could lead to session fixation, session hijacking, or unauthorized access.
To adapt this prompt, replace the placeholders in the REVIEW CONTEXT section with your project's specific parameters. The OUTPUT_SCHEMA is designed to be parsed by an application, so maintain its strict JSON structure. For high-risk deployments, ensure the output is not acted upon automatically; a human security engineer should review the generated lifecycle_analysis and validate the severity ratings before any remediation tickets are filed. The cookie_attribute_audit provides a quick, automatable check that can be compared against your security headers policy.
Prompt Variables
Validate these inputs before sending the session management security review prompt. Missing or malformed variables cause incomplete threat models and false negatives.
| Placeholder | Purpose | Example | Validation Notes |
|---|---|---|---|
[SESSION_DESIGN_DOC] | Full text or structured description of the session management architecture to review | Session creation via OAuth 2.0 authorization code flow with PKCE. Access tokens stored in httpOnly Secure SameSite=Strict cookies. Refresh tokens rotated on each use with reuse detection. Session timeout after 15 min idle, absolute max 8 hours. Logout clears server-side session and invalidates refresh token family. | Must be non-empty and exceed 200 characters. Reject if only a URL or diagram reference without inline text. Parse check for session lifecycle coverage: creation, storage, transmission, refresh, timeout, termination. |
[THREAT_MODEL_SCOPE] | Boundary of the threat analysis: which actors, assets, and trust zones to include | External attacker with network access, malicious insider with valid user credentials, compromised client device. Assets: session tokens, refresh tokens, user PII in session state. | Must contain at least one actor and one asset. Reject generic values like 'all threats'. Validate that scope aligns with [SESSION_DESIGN_DOC] boundaries. |
[COMPLIANCE_STANDARDS] | Regulatory or industry standards the session design must satisfy | OWASP ASVS V3 Session Management, NIST SP 800-63B Section 7, PCI DSS 4.0 Requirement 8 | Allow null if no specific compliance review is needed. If provided, validate each standard name against a known list. Flag unrecognized standards for human confirmation before review. |
[OUTPUT_FORMAT] | Desired structure for the threat analysis output | JSON with fields: threat_id, threat_name, stride_category, affected_component, severity, description, existing_controls, control_gaps, remediation, cvss_vector | Must be one of: JSON, Markdown table, or structured text with headings. Reject unstructured prose requests. If JSON, validate that [OUTPUT_SCHEMA] is provided or use default schema. |
[OUTPUT_SCHEMA] | Explicit JSON schema or field definitions for structured output | {"threat_id": "string", "threat_name": "string", "stride_category": "enum[S,T,R,I,D,E]", "severity": "enum[CRITICAL,HIGH,MEDIUM,LOW,INFO]", "cvss_vector": "string", "description": "string", "affected_component": "string", "existing_controls": ["string"], "control_gaps": ["string"], "remediation": "string"} | Required when [OUTPUT_FORMAT] is JSON. Validate as parseable JSON schema. Reject if schema lacks threat_id, severity, and remediation fields. Warn if schema omits cvss_vector or stride_category. |
[REVIEW_DEPTH] | Level of analysis detail: surface scan, standard review, or deep-dive | deep-dive | Must be one of: surface, standard, deep-dive. Surface: cookie attributes and token visibility only. Standard: full lifecycle including fixation, hijacking, CSRF, and logout. Deep-dive: adds cross-device, token binding, replay, and race condition analysis. Reject unknown values. |
[KNOWN_CONTROLS] | Existing security controls already implemented in the design | WAF with session-aware rules, rate limiting on login endpoint, anomaly detection on token refresh patterns, session invalidation on password change | Allow null if no controls are documented. If provided, each control must be a concrete mechanism, not a goal like 'secure session'. Parse for actionable control descriptions. Flag vague entries for human clarification. |
[EXCLUSION_LIST] | Threat categories or specific attack vectors to exclude from analysis | Physical device theft, social engineering of session tokens, browser extension malware | Allow null. If provided, each exclusion must map to a recognized threat category or attack vector. Reject exclusions that would hide critical session threats like fixation or hijacking. Warn if exclusion list removes more than 30% of standard threat coverage. |
Implementation Harness Notes
How to wire the Session Management Security Review Prompt into a security review pipeline or application with validation, retries, and human review gates.
This prompt is designed to operate as a security review microservice within a larger architecture pipeline. It should be invoked programmatically after a design document or architecture specification has been parsed into a structured text block. The primary integration point is a CI/CD pipeline, a design review tool (like a structured Architecture Decision Record system), or a security chatbot. The harness must treat the model's output as a draft threat assessment, not a final verdict. Every finding must be traceable back to the input text or a well-known standard (like OWASP ASVS V3) before it is accepted.
The implementation harness requires a pre-processing step to extract the session management section from the broader design document. Feed the prompt only the relevant text to avoid context-window pollution and reduce the risk of the model hallucinating threats about unrelated components. After the model returns its JSON output, a validation layer must check for schema compliance: every threat object must have a non-empty finding, risk, and owasp_category field. Any output that fails this structural check should trigger a single retry with a more explicit formatting instruction appended to the original prompt. If the retry also fails, the task must be routed to a human review queue with the raw input and partial output attached.
For high-assurance environments, implement a two-pass evaluation. First, run the prompt as described to generate the initial threat list. Second, run a separate 'verification prompt' that takes the original design text and the generated threats as input, asking the model to confirm or refute each finding with direct quotes from the source material. This significantly reduces false positives. Log every invocation, including the model version, prompt template hash, input token count, and output schema version, to an immutable audit store. This traceability is critical for demonstrating due diligence during compliance audits. Never allow the model's output to automatically block a release; always require a human security engineer to approve or dismiss findings before the review is considered complete.
Expected Output Contract
Defines the JSON schema, field types, and validation rules for the session management security review output. Use this contract to parse, validate, and route the model response in your application harness.
| Field or Element | Type or Format | Required | Validation Rule |
|---|---|---|---|
review_id | string (UUID v4) | Must parse as valid UUID v4. Reject if missing or malformed. | |
session_lifecycle_phase | enum: [creation, storage, transmission, refresh, termination, cross_device] | Must match exactly one of the allowed enum values. Case-sensitive. | |
finding_summary | string (max 280 chars) | Length must be between 10 and 280 characters. Must not be a generic placeholder. | |
threat_category | enum: [fixation, hijacking, replay, csrf, misconfiguration, leakage, timeout_bypass, none] | Must match one of the allowed threat categories. Use 'none' only when no threat is identified. | |
severity | enum: [critical, high, medium, low, informational] | Must match exactly one of the allowed severity levels. Reject if null or empty. | |
affected_cookie_or_token | string or null | If present, must match pattern ^[a-zA-Z0-9_-]+$. Null allowed when no specific token is affected. | |
owasp_asvs_reference | string (format: V<major>.<minor>.<chapter>.<section>) | If present, must match regex ^V\d+.\d+.\d+.\d+$. Null allowed for findings without direct ASVS mapping. | |
remediation_guidance | string (max 1000 chars) | Must contain at least one actionable recommendation. Must not be identical to finding_summary. |
Common Failure Modes
Session management reviews are prone to specific, predictable failures when using LLMs. These cards cover the most common breaks and how to prevent them before they reach production.
Overlooking Cookie Attribute Misconfigurations
What to watch: The model produces a thorough analysis of token exchange and session fixation but misses missing HttpOnly, Secure, or SameSite attributes in the design spec. Guardrail: Add a dedicated pre-prompt checklist requiring explicit validation of every cookie attribute against the OWASP Secure Headers standard before the final report is generated.
Ignoring Cross-Device Session Consistency
What to watch: The review focuses entirely on single-device session lifecycle and fails to analyze risks from concurrent sessions, device fingerprinting gaps, or session token binding across multiple user agents. Guardrail: Include a mandatory section in the output schema for 'Cross-Device Threat Analysis' and trigger a retry if the model fails to populate it with specific findings.
Hallucinating Token Binding Implementations
What to watch: The model confidently recommends 'token binding' or 'channel binding' as a mitigation without verifying whether the protocol version in the design document actually supports it, leading to impossible implementation advice. Guardrail: Require the model to cite specific protocol sections or configuration parameters from the provided design doc for every recommended mitigation. Flag recommendations without direct source evidence for human review.
Missing Session Termination Race Conditions
What to watch: The analysis covers logout functionality but fails to identify race conditions where a terminated session token can still be used for a brief window due to asynchronous revocation or cache propagation delays. Guardrail: Add a specific evaluation criterion that checks for the presence of 'revocation propagation delay' analysis in the output. If absent, re-prompt with a focus on distributed systems consistency.
Confusing Session Timeout Types
What to watch: The model conflates absolute timeout, idle timeout, and token expiry, recommending a single value that satisfies one but breaks the security posture of another (e.g., setting an idle timeout too long to meet a usability requirement). Guardrail: Structure the output schema to require separate, explicit recommendations for absolute timeout, idle timeout, and refresh token lifetime, with a mandatory trade-off justification for each.
Neglecting Refresh Token Rotation and Reuse Detection
What to watch: The review validates the refresh flow but fails to flag a design where a stolen refresh token can be used indefinitely or where a previously used refresh token is not invalidated, enabling replay attacks. Guardrail: Include a specific pass/fail eval check for 'Refresh Token Reuse Detection' in the harness. If the model's output does not explicitly mention rotation and reuse detection, the review is marked incomplete.
Evaluation Rubric
Use this rubric to test the Session Management Security Review Prompt before integrating it into a production review workflow. Each criterion validates a specific quality dimension of the generated threat analysis.
| Criterion | Pass Standard | Failure Signal | Test Method |
|---|---|---|---|
Cookie Attribute Coverage | Output identifies missing or misconfigured HttpOnly, Secure, SameSite attributes for every session cookie described in [DESIGN_DOC] | Output omits one or more session cookies mentioned in the input or fails to flag a missing Secure attribute on a cookie used over HTTPS | Parse output for cookie names; cross-reference with [DESIGN_DOC] cookie inventory; assert each cookie has attribute assessment |
Session Fixation Detection | Output explicitly addresses whether the session ID is regenerated after authentication and flags any pre-auth to post-auth ID reuse | Output does not mention session fixation or regeneration, or incorrectly states fixation is mitigated when [DESIGN_DOC] shows no regeneration step | Keyword search for 'fixation' and 'regeneration'; if [DESIGN_DOC] describes login flow, assert regeneration recommendation is present |
Token Binding Assessment | Output evaluates whether session tokens are bound to client attributes such as IP, User-Agent, or TLS channel and identifies replay risks | Output ignores token binding entirely or recommends IP binding without noting mobility and NAT breakage risks | Check for 'token binding' or 'session binding' section; assert both binding recommendation and limitation notes exist |
Timeout and Lifecycle Completeness | Output covers absolute timeout, idle timeout, refresh token rotation, and server-side invalidation for every session type in [DESIGN_DOC] | Output only mentions one timeout type or fails to distinguish between refresh token and access token lifecycle | Parse output for timeout values; assert absolute, idle, and refresh rotation are each addressed; compare against [DESIGN_DOC] session types |
Cross-Device and Concurrent Session Analysis | Output identifies whether concurrent sessions are allowed, detects missing device-limit controls, and flags cross-device token sharing risks | Output does not mention concurrent session policy or assumes single-device use without evidence from [DESIGN_DOC] | Search output for 'concurrent', 'device', 'multiple sessions'; assert policy assessment exists; if [DESIGN_DOC] is silent, assert output flags the ambiguity |
Logout and Session Termination Coverage | Output validates that logout invalidates both client-side and server-side session state and checks for missing single-logout propagation in SSO designs | Output only addresses client-side cookie deletion without server-side invalidation, or ignores SSO logout propagation when [DESIGN_DOC] includes federated identity | Check for 'logout', 'invalidation', 'server-side'; if [DESIGN_DOC] mentions SSO or federation, assert single-logout or propagation risk is flagged |
Threat-to-Control Mapping | Every identified threat is mapped to at least one existing or recommended control; no orphan threats without mitigation guidance | Output lists threats without corresponding controls, or recommends controls that do not address the stated threat mechanism | Extract threat and control lists; assert each threat has at least one linked control; spot-check three threat-control pairs for mechanistic relevance |
OWASP ASVS Traceability | Output references relevant OWASP ASVS v4.0 sections (e.g., V3.2 Session Binding, V3.3 Session Termination) for each major finding category | Output makes no reference to ASVS or cites incorrect section numbers that do not match the finding | Search for 'ASVS' or 'V3.'; assert at least three distinct section references; validate section numbers against OWASP ASVS v4.0 session management requirements |
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 session flow document. Drop strict output schema requirements and accept a narrative threat list instead of structured JSON. Focus on getting useful findings, not perfect formatting.
Prompt modification
Remove the [OUTPUT_SCHEMA] block and replace with: Return findings as a bulleted list organized by session lifecycle phase. Reduce [CONSTRAINTS] to: Flag only high-severity threats.
Watch for
- Missing cookie attribute checks (Secure, HttpOnly, SameSite)
- Overly broad threat descriptions without specific attack paths
- No distinction between session fixation and session hijacking

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