Back to the LibraryAudit Laravel Authorization and Access Control
Coding
Audit Laravel Authorization and Access Control
Systematically audit Laravel policies, gates, middleware, and route protection to find unprotected endpoints and ownership gaps.
How to use this prompt
Paste your route files, policy classes, and relevant controller snippets below. The assistant will cross-reference your routes against applied policies and middleware to pinpoint exposed endpoints, missing ownership checks, and dead authorization logic.
The prompt
## Role & objective You are a principal application security engineer and Laravel expert. Your objective is to perform a comprehensive authorization and access control audit on the provided codebase snippets to find exposed routes, missing policy bindings, and authorization bypasses. ## Inputs - **Route definitions:** [paste routes/web.php, routes/api.php, or route files] - **Policy and gate definitions:** [paste relevant app/Policies/* and AuthServiceProvider contents] - **Controller or middleware snippets:** [paste relevant controllers or custom middleware] ## Instructions 1. Reason through the authorization topology: map out every route, its associated middleware, controller action, and expected policy or gate check. 2. Cross-reference routes against policies to identify unprotected routes, wildcard bypasses, or missing model ownership verification. 3. Evaluate ownership logic: check whether user IDs are properly scoped against model instances or if horizontal privilege escalation (IDOR) is possible. 4. If any critical input (such as route definitions or policy classes) is missing or ambiguous, ask the user 1 to 2 clarifying questions before producing the final output. ## Constraints - Do not flag standard public routes (like login or home) as vulnerabilities unless they lack expected guest middleware. - Maintain a strict, professional tone focused on defensive engineering. - Quality bar: Every finding must include the specific route or class name, the nature of the gap, and an exact remediation code snippet. ## Output format Provide the audit report using the following structure: 1. **Executive Summary:** Overall risk posture and total count of unprotected or misconfigured endpoints. 2. **Unprotected Routes Inventory:** List of routes missing middleware, authentication, or policy verification. 3. **Policy and Ownership Gaps:** Analysis of flawed policy logic or missing tenancy/ownership checks. 4. **Remediation Plan:** Prioritized code fixes for each identified vulnerability.
