This prompt is designed for security engineers and architects who need to review OAuth 2.0 and OpenID Connect (OIDC) flow designs before implementation. It accepts a flow description, grant type, and architectural context, then produces a structured threat analysis covering redirect validation, token leakage, scope over-provisioning, and RFC compliance gaps. Use this prompt during design review gates, security architecture assessments, or when onboarding a new identity provider integration.
Prompt
OAuth 2.0 and OpenID Connect Flow Security Review Prompt

When to Use This Prompt
Defines the job-to-be-done, ideal user, required context, and limitations for the OAuth 2.0 and OpenID Connect flow security review prompt.
The prompt assumes the reviewer has access to a flow diagram, client configuration details, and the intended authorization server behavior. It is most effective when the [FLOW_DESCRIPTION] includes the specific endpoints, client types (confidential vs. public), and token handling mechanisms in play. The output is a threat list organized by attack surface—redirect URI manipulation, CSRF state parameter weaknesses, PKCE bypass, token storage risks, and scope mismatch—with each threat mapped to the relevant RFC section (e.g., RFC 6749, RFC 7636, RFC 6819) for traceability.
This prompt is not a substitute for a full penetration test or a formal threat model; it is a design-time review tool that surfaces protocol-level risks early. Do not use it to review live production traffic, to generate compliance attestations, or as the sole security gate before deployment. For high-risk flows involving financial transactions, healthcare data, or cross-tenant access, pair the output with a manual review by a security architect and a runtime token-inspection test plan.
Use Case Fit
Where this prompt works and where it does not. Use these cards to decide if the OAuth 2.0 and OpenID Connect Flow Security Review Prompt fits your current review task.
Good Fit: Structured Flow Reviews
Use when: you have a complete OAuth 2.0 or OIDC flow description including grant type, endpoints, client configuration, and token handling. The prompt excels at systematic threat enumeration against RFC standards. Guardrail: provide the full flow specification as input; partial descriptions produce incomplete threat lists.
Bad Fit: Runtime Incident Response
Avoid when: you are investigating an active token compromise or session hijacking incident. This prompt is designed for design-time review, not live forensics. Guardrail: use incident response and log analysis prompts for active security events; reserve this prompt for architecture review cycles.
Required Input: Complete Flow Specification
What to watch: missing grant type, redirect URIs, client authentication method, token storage, or refresh token behavior. Incomplete inputs produce generic threats that miss implementation-specific risks. Guardrail: validate that your input covers all OAuth 2.0 roles (client, authorization server, resource server) and token lifecycle stages before running the review.
Operational Risk: False Confidence
What to watch: the prompt produces a threat list that appears comprehensive, but it cannot detect implementation bugs, misconfigured infrastructure, or custom protocol deviations not described in the input. Guardrail: always follow the prompt output with manual penetration testing and configuration review; treat the output as a starting point, not a sign-off.
Good Fit: Compliance Evidence Generation
Use when: you need structured security review documentation for SOC 2, ISO 27001, or internal audit requirements. The prompt produces traceable threat-to-control mappings. Guardrail: ensure a human security reviewer signs off on findings before submitting as audit evidence; the prompt assists review, it does not replace qualified judgment.
Bad Fit: Multi-Protocol Comparisons
Avoid when: you need to compare OAuth 2.0 against SAML, WebAuthn, or custom authentication protocols. This prompt focuses on OAuth 2.0 and OIDC threat enumeration, not cross-protocol trade-off analysis. Guardrail: use a dedicated protocol comparison prompt for architecture decision records; use this prompt only after OAuth 2.0 or OIDC is selected as the implementation path.
Copy-Ready Prompt Template
A reusable prompt template for conducting a structured security review of OAuth 2.0 and OpenID Connect flow designs.
This prompt template is designed to be copied directly into your AI harness or prompt management system. It uses square-bracket placeholders for all variable inputs, allowing you to adapt it to different grant types, system designs, and risk profiles without modifying the core instruction structure. The template instructs the model to act as a security architect and produce a structured threat analysis, not a generic security opinion.
textYou are a security architect specializing in authentication and authorization protocols. Your task is to perform a structured security review of an OAuth 2.0 or OpenID Connect flow design. ## INPUT [FLOW_DESIGN_DOCUMENT] ## REVIEW PARAMETERS - Grant Type: [GRANT_TYPE] - Client Type: [CLIENT_TYPE] - Token Binding Method: [TOKEN_BINDING] - Identity Provider: [IDP] - Risk Level: [RISK_LEVEL] ## CONSTRAINTS - Base your analysis strictly on the provided design document and the RFCs for OAuth 2.0 (RFC 6749), OAuth 2.1 (draft), and OpenID Connect (OIDC Core 1.0). - Do not invent threats for components not described in the input. - If the design document omits a critical detail (e.g., redirect URI validation, PKCE, state parameter), flag it as a finding with "INSUFFICIENT INFORMATION" severity. - For each finding, cite the specific RFC section or OWASP ASVS requirement that applies. ## OUTPUT SCHEMA Return a valid JSON object with the following structure: { "review_summary": { "grant_type": "string", "overall_risk": "LOW|MEDIUM|HIGH|CRITICAL", "findings_count": "integer", "critical_findings_count": "integer" }, "findings": [ { "id": "F-001", "category": "REDIRECT_VALIDATION|TOKEN_HANDLING|SCOPE_PROVISIONING|SESSION_MANAGEMENT|CSRF|CLIENT_AUTH|DISCOVERY|OTHER", "severity": "CRITICAL|HIGH|MEDIUM|LOW|INSUFFICIENT_INFORMATION", "title": "string", "description": "string", "rfc_reference": "string", "owasp_asvs_reference": "string", "remediation": "string" } ], "flow_completeness": { "missing_elements": ["string"], "non_compliant_elements": ["string"] } } ## INSTRUCTIONS 1. Parse the provided flow design document and identify the authorization flow steps. 2. For the specified grant type, enumerate the mandatory security controls from the relevant RFCs. 3. Compare the design against each mandatory control and identify gaps. 4. For each gap, produce a finding with a unique ID, category, severity, and remediation. 5. Assess overall risk based on the highest-severity finding and the number of critical findings. 6. Populate the flow_completeness object with any missing or non-compliant elements.
To adapt this template, replace each placeholder with concrete values from your review context. The [FLOW_DESIGN_DOCUMENT] should contain the full text of the architecture document, sequence diagram description, or configuration specification you are reviewing. The [GRANT_TYPE] must be one of authorization_code, client_credentials, refresh_token, or device_code—avoid reviewing the deprecated implicit grant without an explicit decision to do so. The [RISK_LEVEL] parameter should reflect your organization's data classification for the resources protected by this flow, which influences the severity calibration in the model's output.
Before deploying this prompt in a production review pipeline, validate the output against a known set of golden test cases. At minimum, test with a deliberately broken flow that omits PKCE, a flow missing redirect URI validation, and a compliant flow to ensure the model correctly distinguishes between secure and insecure designs. If the review is for a high-risk system, route all CRITICAL findings for human security architect review before accepting the output as final.
Prompt Variables
Inputs the prompt needs to work reliably. Each placeholder must be replaced with concrete values from your flow design.
| Placeholder | Purpose | Example | Validation Notes |
|---|---|---|---|
[FLOW_DESIGN_DOCUMENT] | The full text of the OAuth 2.0 or OpenID Connect flow design to be reviewed | Architecture decision record describing an authorization code flow with PKCE for a native mobile app | Must be non-empty plain text or markdown. Minimum 200 characters to ensure sufficient design detail for a meaningful review. |
[GRANT_TYPE] | The specific OAuth 2.0 grant type or OpenID Connect flow under review | authorization_code | Must be one of: authorization_code, client_credentials, refresh_token, implicit, password, device_code, hybrid, or a custom grant name with a description. Controls which threat model is applied. |
[CLIENT_TYPE] | The OAuth 2.0 client type as defined by RFC 6749 | public | Must be one of: public, confidential. Determines whether the client can safely hold a client secret and influences token storage and PKCE requirements. |
[REVIEW_SCOPE] | The depth and focus of the security review | full | Must be one of: full, redirect_validation, token_handling, scope_audit, rfc_compliance. Controls which sections of the review are generated and which checks are prioritized. |
[COMPLIANCE_FRAMEWORKS] | Optional list of compliance standards to check against | ["OWASP ASVS V4.0.3", "FAPI 2.0"] | Must be a JSON array of strings or null. If provided, each framework name must match a known standard. If null, only RFC compliance is checked. |
[OUTPUT_FORMAT] | The desired structure for the security review output | threat_register | Must be one of: threat_register, finding_list, rfc_compliance_matrix, full_report. Determines the output schema and level of detail. |
[KNOWN_ASSUMPTIONS] | Explicit design assumptions the reviewer should accept without challenge | ["The authorization server is trusted and not compromised", "TLS 1.3 is enforced for all endpoints"] | Must be a JSON array of strings or null. Each assumption is treated as a boundary condition. Threats that rely on violating these assumptions are noted but not flagged as actionable. |
[PREVIOUS_REVIEW_ID] | Optional identifier for a prior review to enable delta analysis | null | Must be a string matching a previous review ID in your system or null. When provided, the output includes a changes-since-last-review section highlighting new, resolved, and unchanged findings. |
Implementation Harness Notes
How to wire the OAuth 2.0 and OpenID Connect flow security review prompt into an application or CI/CD pipeline with validation, retries, and human review gates.
This prompt is designed to operate as a security review microservice within a larger architecture review pipeline. It expects a structured input payload containing the grant type, redirect URIs, client configuration, token endpoint details, and scope definitions. The prompt should be called programmatically via an API (OpenAI, Anthropic, or a self-hosted model) with the response parsed into a structured JSON output for downstream processing. Because the output contains security findings that may influence architectural decisions, the harness must enforce strict output validation before any findings are accepted or displayed.
Integration pattern: Wrap the prompt call in a function that (1) assembles the input from your design document or configuration file, (2) calls the model with response_format set to json_object (or equivalent structured output mode), (3) validates the returned JSON against a defined schema, and (4) routes findings to the appropriate review queue. For high-risk flows (authorization code with PKCE, client credentials for service accounts), implement a human review gate: if the model flags a severity: critical finding or identifies a violation of RFC 6749/7636/8252, the output must be surfaced in a review interface (Jira, Linear, GitHub Issue) with the raw model response and source evidence attached. Never auto-apply security findings to production configurations without human sign-off.
Validation and retry logic: Define a JSON schema for the expected output—fields like grant_type, threats[], misconfigurations[], rfc_compliance_gaps[], and remediation_steps[]. After each model call, validate the response against this schema. If validation fails, implement a single retry with the error message appended to the prompt as [VALIDATION_ERROR]. If the retry also fails, log the raw response, flag the review as incomplete, and escalate to a human reviewer. For model choice, prefer models with strong structured output support (GPT-4o, Claude 3.5 Sonnet) and set temperature=0 to maximize consistency. Log every call with the input hash, model version, latency, token usage, and validation status for auditability and cost tracking.
What to avoid: Do not use this prompt as a real-time gate in an authentication flow—it is a design-time review tool, not a runtime policy engine. Do not feed live tokens, secrets, or production client credentials into the prompt; use redacted or synthetic representations. If the prompt identifies a finding that contradicts your existing security controls, treat it as a hypothesis to investigate, not a ground-truth verdict. Always cross-reference model findings against your organization's specific OAuth/OIDC implementation, identity provider documentation, and threat model before taking action.
Expected Output Contract
Fields, format, and validation rules for the structured JSON response returned by the OAuth 2.0 and OpenID Connect Flow Security Review Prompt. Use this contract to build a parser, validator, or retry harness before integrating the prompt into a security review pipeline.
| Field or Element | Type or Format | Required | Validation Rule |
|---|---|---|---|
review_id | string (UUID v4) | Must parse as valid UUID v4. Generate if absent; reject if malformed. | |
grant_type | enum: authorization_code, client_credentials, refresh_token, implicit, hybrid, device_code, jwt_bearer, token_exchange | Must exactly match one of the listed grant types. Reject unknown values and request clarification. | |
flow_diagram_summary | string (plain text, max 500 chars) | Must be non-empty. Must contain at least one reference to a redirect, token endpoint, or client. Reject if purely generic. | |
threats | array of threat objects | Must be a non-empty array. Each element must conform to the threat object schema below. Reject if array is empty or contains non-object elements. | |
threats[].id | string (THREAT-XXX format) | Must match pattern ^THREAT-\d{3}$. Must be unique within the array. Reject duplicates. | |
threats[].category | enum: redirect_validation, token_leakage, scope_over_provisioning, client_authentication, replay, csrf, pkce_bypass, session_fixation, id_token_validation, other | Must be one of the listed categories. Reject unknown categories. | |
threats[].severity | enum: critical, high, medium, low, informational | Must be one of the listed severity levels. Reject if missing or invalid. | |
threats[].description | string (plain text, max 1000 chars) | Must describe a specific, actionable threat relevant to the grant_type. Must reference at least one RFC section or OWASP ASVS requirement. Reject if vague or untethered to a standard. | |
threats[].affected_component | string (plain text, max 200 chars) | Must name a concrete component: authorization server, client, resource server, redirect URI handler, token store, or user-agent. Reject if 'system' or 'application' without specificity. | |
threats[].mitigation | string (plain text, max 1000 chars) | Must propose a specific, implementable mitigation. Must reference a control: PKCE, state param, DPoP, mTLS, exact redirect URI matching, token binding, or scope restriction. Reject if mitigation is 'use best practices' without detail. | |
threats[].rfc_reference | string (RFC XXXX Section Y.Z format) | If present, must match pattern ^RFC \d{4} Section \d+(.\d+)*$. Reject if format is wrong. Null allowed if no direct RFC reference. | |
threats[].owasp_asvs_reference | string (ASVS VX.Y.Z format) | If present, must match pattern ^ASVS V\d+.\d+.\d+$. Reject if format is wrong. Null allowed if no direct ASVS reference. | |
overall_risk_score | enum: critical, high, medium, low | Must be the highest severity among non-mitigated threats. If all threats have mitigations, score may be lower. Reject if score is lower than the highest unmitigated threat severity. | |
missing_controls | array of strings | Must list security controls absent from the reviewed flow. Each string must be a specific control name: PKCE, state parameter, DPoP, mTLS, exact redirect URI matching, token binding, sender-constrained tokens, or scope pre-registration. Reject if array contains generic phrases like 'better security'. | |
review_timestamp | string (ISO 8601 UTC) | Must parse as valid ISO 8601 datetime in UTC. Reject if timezone is missing or non-UTC. | |
model_version | string (provider:model format) | Must match pattern ^[a-z]+:[a-z0-9.-]+$. Reject if provider or model name is missing. |
Common Failure Modes
The most common ways this prompt produces unreliable output in production, why they happen, and how to guard against them.
Hallucinated RFC Violations
What to watch: The model invents plausible-sounding but non-existent RFC 6749 or 6750 violations, or misattributes a real vulnerability to the wrong section of the spec. This is especially common when the input design doc is sparse and the model fills gaps with confident fabrication. Guardrail: Require the model to cite specific RFC section numbers and quote the relevant normative language. Add a post-generation validation step that verifies each cited section actually exists and contains the claimed requirement.
Grant-Type Confusion
What to watch: The model applies authorization code flow threats to a client credentials flow, or recommends PKCE for a machine-to-machine service account where it is irrelevant. This happens when the input does not explicitly name the grant type and the model defaults to the most common flow. Guardrail: Make [GRANT_TYPE] a required, enumerated input field in the prompt harness. Reject inputs that do not specify one of: authorization_code, client_credentials, refresh_token, or device_code. Add a pre-check that warns if the described flow contradicts the declared grant type.
Missing Redirect URI Validation Threats
What to watch: The model overlooks open redirector vulnerabilities, wildcard redirect URI patterns, or missing exact-match validation. This is the most common real-world OAuth vulnerability and the prompt often skips it when the input focuses on token handling rather than the full authorization request lifecycle. Guardrail: Include a dedicated checklist item in the prompt instructions that explicitly asks: 'Verify redirect URI registration, validation logic, and whether open redirectors are possible.' Add an eval assertion that the output must mention redirect URI security for any authorization code or implicit flow review.
Token Storage Recommendations Without Context
What to watch: The model recommends 'store tokens securely' without specifying whether the client is a SPA, mobile app, or confidential server, leading to inappropriate guidance like recommending localStorage for a public client. Guardrail: Require [CLIENT_TYPE] as a mandatory input. Map recommendations to client-specific best practices: BFF pattern for SPAs, secure enclave for mobile, encrypted database for confidential clients. Add eval criteria that flag generic storage advice when client type is provided.
Scope Over-Provisioning Missed in Complex Systems
What to watch: The model correctly identifies individual scope issues but misses systemic over-provisioning where multiple services each request broad scopes that collectively grant excessive access across trust boundaries. Guardrail: Add a cross-service scope aggregation step to the prompt: 'Review all requested scopes across every service in the design. Identify combinations that, when aggregated, exceed least-privilege boundaries.' Include an eval check that the output contains a cross-service scope analysis when multiple resource servers are present.
Implicit Flow Accepted Without Challenge
What to watch: The model reviews an implicit flow design without flagging it as deprecated per current OAuth 2.0 Security Best Current Practice (BCP). It treats the flow as valid and only looks for implementation bugs rather than questioning the architectural choice. Guardrail: Add a hard rule in the system prompt: 'If the design uses the implicit grant, flag it as deprecated per OAuth 2.0 Security BCP and recommend migration to authorization code with PKCE. Do not review implicit flow implementations without this warning.' Add an eval assertion that any output mentioning implicit flow includes a deprecation warning.
Evaluation Rubric
How to test output quality before shipping. Run these checks against a golden dataset of known OAuth flow designs with documented vulnerabilities.
| Criterion | Pass Standard | Failure Signal | Test Method |
|---|---|---|---|
Grant Type Correctness | Output correctly identifies the OAuth grant type(s) described in [DESIGN_DOC] and maps threats to the appropriate RFC section | Threat listed for authorization code flow is applied to client credentials flow, or grant type is misidentified entirely | Compare output grant type label against golden dataset label; require exact match on grant type enumeration |
Redirect URI Validation Coverage | Output flags at least one redirect URI vulnerability if the golden dataset contains an open redirect, unregistered URI, or wildcard pattern | No redirect URI threats listed when golden dataset contains a known redirect vulnerability | Check for presence of redirect-related threat category; if golden label has redirect_vuln=true, output must contain redirect threat |
PKCE Requirement Detection | Output recommends PKCE when authorization code flow is used without PKCE in a public client context | Output omits PKCE recommendation for a public client using authorization code flow without PKCE | Parse output for PKCE mention; cross-reference with golden dataset public_client and pkce_required flags |
Token Leakage Threat Identification | Output identifies at least one token leakage vector (browser history, logs, referrer header, or mobile app storage) when applicable | Output lists only generic injection threats and misses token storage or transmission leakage paths | Search output for token leakage keywords (referrer, history, logs, storage); match against golden dataset token_leakage_vectors list |
Scope Over-Provisioning Analysis | Output flags excessive scope requests or missing scope validation when golden dataset contains over-provisioned scopes | Output accepts requested scopes without comment when golden dataset shows scope not required for the described functionality | Compare output scope assessment against golden dataset scope_overprovisioned flag; require match on pass/fail |
State Parameter Anti-CSRF Check | Output recommends state parameter for authorization code flow and identifies CSRF risk when state is absent | Output does not mention state parameter or CSRF when golden dataset shows authorization code flow without state | Check output for state parameter and CSRF keywords; cross-reference with golden dataset state_required=true |
Token Binding or Sender-Constrained Token Recommendation | Output recommends token binding, DPoP, or mTLS for high-risk flows when golden dataset indicates bearer token usage in sensitive context | Output treats bearer tokens as acceptable without qualification when golden dataset sensitivity is high | Search output for DPoP, token binding, mTLS, or sender-constrained keywords; match against golden dataset high_sensitivity flag |
RFC Reference Accuracy | Output cites specific RFC sections (e.g., RFC 6749 Section 4.1, RFC 7636) that are relevant to identified threats | Output makes generic references to OAuth 2.0 without section numbers, or cites incorrect RFC sections | Extract RFC citations from output; verify each citation exists and is relevant to the threat category using a citation validation script |
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
Add a strict JSON output schema, retry logic on parse failure, and structured eval cases. Include a [CONSTRAINTS] block that enforces RFC 6749, RFC 7636, and OAuth 2.0 Security Best Current Practice compliance. Wire the prompt into a CI pipeline that runs on every auth config change.
code{ "flow_type": "[GRANT_TYPE]", "threats": [ { "id": "THREAT-XXX", "category": "[redirect_validation|token_leakage|scope_overprovision|csrf|pkce_missing|...]", "severity": "[CRITICAL|HIGH|MEDIUM|LOW]", "description": "...", "rfc_reference": "RFC XXXX Section Y", "remediation": "..." } ], "compliance_gaps": ["..."], "requires_human_review": true }
Watch for
- Silent format drift when models change output structure
- Missing human review gate for CRITICAL findings
- False negatives on implicit flow deprecation warnings

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