pekral/cursor-rules/laravel-authorization-review

Claude Code and agent skill by pekral/cursor-rules

Trust tier 3
  • community
Source check pending

Checking that the SKILL.md file is still in the repository.

Use when reviewing authorization / access control in a Laravel project — find IDOR / broken object-level authorization (BOLA), audit which routes are unprotected, check policy / gate coverage, or sanity-check a new endpoint in a PR. Walks the authorization chain of every HTTP route (middleware → authorize/policy/gate → query scoping → API Resource output), anchors every finding to real `php artisan route:list --json` output plus a cited `file:line`, classifies by confidence, and produces a per-route coverage map. Read-only / advise-only — never edits code.

Install

npx vskill@latest install pekral/cursor-rules/laravel-authorization-review

SKILL.md

The same SKILL.md was published earlier as pekral/cursor-rules/laravel-authorization-review.

Laravel Authorization Review

SAST tells you where data flows. This tells you where it flows to the wrong user.

This skill is the judgment layer for the one category automated scanners structurally cannot do: broken object-level authorization (IDOR / BOLA) — #1 in the OWASP API Security Top 10. Taint scanners trace untrusted input; they cannot decide whether Order::find($id) should have been scoped to the current user. That is a question about intent, reasoned across middleware, controller, policy, and query.

The skill is trustworthy because every finding traces to a ground-truth anchor: php artisan route:list --json is the deterministic inventory of every endpoint and its merged middleware. If you cannot point to both a real route and a cited file:line, you do not report it.


Constraints

  • Apply @rules/php/core-standards.mdc
  • Apply @rules/laravel/laravel.mdc and @rules/laravel/architecture.mdc
  • Apply @rules/security/backend.md — Database (authentication & authorization, least privilege) and Safe Validation & Error Messages (a 403-vs-404 distinction that confirms a resource exists is itself an authorization-granularity leak)
  • Apply @rules/code-review/general.mdc — map every finding onto the CR severity scale (Critical / Moderate / Minor) so this skill plugs into a Laravel CR run
  • Advise-only. Reads files and runs one read-only command (php artisan route:list --json). Never edits routes, controllers, policies, or any source; emits a report plus fix sketches for a human to apply.
  • Output in English

Use when

  • The user wants to review authorization / access control or hunt for IDOR (broken object-level authorization)
  • A Laravel CR run needs to verify that new or changed routes are scoped to their owner
  • The user asks "which routes have no auth", "is this endpoint scoped to the owner", "do my controllers check policies", or "audit access control before launch"
  • A PR introduces or changes routes, controllers, policies, gates, FormRequests, or API Resources

This skill complements @skills/laravel-security/SKILL.md (broad 7-area audit) and the generic @skills/security-review/SKILL.md by going deep on the authorization chain with a route-inventory anchor. Use it as the focused authorization lane inside a Laravel CR.


Method

Work the steps in order. Step 1 is non-negotiable: every finding traces to the real route inventory and a cited controller line, never to a guess about what the code "probably" does.

1. Ground truth from route:list
  1. Confirm it's a Laravel project — artisan at the repo root plus app/ / routes/. If absent, stop and say so.
  2. Get the route inventory — the anchor:

``bash php artisan route:list --json ` Returns, per route: HTTP method, uri, name, the full merged middleware list, and action. This is the spine you reason about and the source of truth for *what middleware actually applies* (route-group middleware is already merged in). > --json renders middleware as **resolved class strings**, not aliases: > can:update,post → Illuminate\Auth\Middleware\Authorize:update,post; > auth:sanctum → Illuminate\Auth\Middleware\Authenticate:sanctum; a custom > role:admin → its own class. **Never decide "no authz" by grepping for the literal > can:** — match the Authorize: / class form too, and read any custom middleware > class. See references/auth-patterns.md` §2a.

  1. Scope the review to application routes — skip framework / vendor / telescope / horizon / _ignition routes unless asked. For a PR / diff, intersect the route list with the changed files.
  2. Fallback when the app won't boot: parse routes/*.php statically + Grep for Route:: / middleware, say so explicitly, and drop every finding one confidence level. Never silently substitute a guess for the real list.

> Laravel 11/12 boots route:list on defaults even with no .env — a missing .env is not a reliable failure trigger. Real boot failures: a missing PHP extension, or a service provider that hits the DB / cache at boot. If it's a missing extension you can enable, prefer fixing the boot (php -d extension=gd artisan route:list --json) over the lossy static fallback. Glob all of routes/*.php — apps split into admin.php, api.base.php, etc.

2. The authorization chain — four layers per route

On a large app, establish the convention first, then audit by exception: find how the app authorizes (base controller AuthorizesRequests? policies auto-discovered or registered? object scoping inline or in a repository / custom Builder? auth per-route or per group?), then most routes are a fast conformance check and the findings are the deviations.

For each in-scope route, record which layers are present:

LayerPresent when (fact you can cite)Where to look
1 · Authenticationauth, auth:sanctum, auth:api, or a custom guard in the route's middlewareroute:list
2 · Authorizationcan: middleware (renders as Illuminate\Auth\Middleware\Authorize:<ability>) OR Gate::authorize/allows/denies / $this->authorize() (needs AuthorizesRequests) / $user->can() OR authorizeResource() in the constructor OR a FormRequest whose authorize() returns a real checkroute:list + controller / request
3 · Object scoping (IDOR core)the record is fetched scoped to the actor ($request->user()->posts()->findOrFail(...), scoped route binding) OR authorized against the bound model (authorize('update', $post))controller method
4 · Policy existsan App\Policies\{Model}Policy is auto-discovered, bound via #[UsePolicy], or registered with Gate::policy(...) (in AppServiceProvider::boot() on L11+, or AuthServiceProvider::$policies on ≤10)filesystem + provider
Laravel-version note. Since Laravel 11 the base Controller is empty and does
not include AuthorizesRequests, so $this->authorize() / authorizeResource()
exist only when the controller adds use AuthorizesRequests;; the always-available
form is Gate::authorize(...). AuthServiceProvider is gone from the skeleton —
policies are registered in AppServiceProvider::boot(), via #[UsePolicy], or
auto-discovered. Recognize all of these. See references/auth-patterns.md.
3. The IDOR core — object-level authorization (the flagship)
  • Implicit route-model binding resolves, it does NOT authorize. public function update(Post $post) loads anyone's post by id. Without authorize('update', $post) or owner-scoping, that's IDOR — the single most common Laravel access-control bug.
  • `Model::find($request->id)` / `findOrFail($id)` then mutate / return, with no policy call and no where('user_id', ...) / relationship scoping → finding, severity by how clearly the model is user-owned.
  • Actor-selected target from request input (IDOR on write — the worst case). When the record to write is chosen by an id from the request body / query (User::findOrFail($request->input('user_id'))->update(...)) with no ownership check, that's a confirmed cross-account write: High confidence even without route-model binding — the attacker names the victim directly. Do not soften it to "verify".
  • Scoped bindings count: Route::scopeBindings() or a nested resource scoping the child to the parent (users.posts resolving $post through $user->posts()) is object scoping — credit it.
  • Mass-assignment adjacency: $model->update($request->all()) where $fillable includes an ownership / role key (user_id, team_id, is_admin) is privilege escalation even when the row was scoped — note as a related finding.

To judge "should this be scoped?", look for ownership signals: user_id / team_id / tenant_id columns, belongsTo(User::class), a global scope, or the user's relationship methods. If you can't establish the model is owned, the finding is Moderate / Minor and phrased as "verify", not asserted as a hole.

Ownership can be conditional on edition / config / feature flag — the same model
shared-by-design in one mode and user-owned in another. Say which mode the finding
applies to ("cross-user read only under the Plus license"), don't assert or dismiss flatly.
4. API Resource output — the second leak surface

An endpoint can authorize the action correctly and still leak data in the response. For routes returning a JsonResource / ResourceCollection (or a raw model / ->toArray()):

  • Field-level: flag resources exposing ownership / internal fields — user_id, email, *_token, is_admin, password hashes, other users' PII — without a per-field guard (when(), mergeWhen(), conditional on $request->user()).
  • Row-level: flag a collection endpoint returning records not scoped to the actor (PostResource::collection(Post::all())) — IDOR at the list level.

Confidence here is Moderate (field sensitivity is a judgment) — cite the resource file:line and the exact field.

5. False-positive control (first-class, not a footnote)

A security tool dies from false positives. Before flagging, apply these filters — and when in doubt, lower the confidence, don't drop or inflate the finding:

  • Public-by-design routes — login, register, password/*, email verification, landing / public listings, and signature-verified webhooks are meant to be unauthenticated. See references/public-by-design.md. If a route only looks public, mark "assumed public — confirm".
  • Authorization can live in layers you must actually check — a missing $this->authorize() is not a finding if a can: middleware, authorizeResource(), or a FormRequest already covers it. Verify all four layers first.
  • `FormRequest::authorize()` returning `true` is only a finding when the route is otherwise unprotected and touches owned data; on a public / separately-authorized route it's intentional ("verify intent").
  • Admin / global contexts — a route behind an admin / role middleware legitimately queries across all users; don't flag those unscoped queries as IDOR.
6. Classify each finding (confidence + CR severity)

One row per finding, most severe wins. Confidence is mandatory and travels with an evidence chain. Map onto the CR scale per @rules/code-review/general.mdc:

SignalConfidenceCR severity
State-changing or owned-data route with no auth AND no authz AND no scopingHigh — structuralCritical
FormRequest::authorize(){ return true; } on an otherwise-unprotected owned-data routeHighCritical
Cross-account write — record to mutate selected from request input, no ownership check, on an authenticated routeHighCritical
Route-model binding / find($id) on a likely-owned model, no authorize() and no owner scopingMediumModerate
Model::all() / unscoped query, or an API Resource exposing owned / internal fieldsMedium / LowModerate / Minor
No policy for a managed model, ad-hoc inline check instead of a policy, mass-assignment of ownership keysLow — defense-in-depthMinor
All applicable layers present—Covered ✅

This is the start of the file. Read the full SKILL.md on GitHub.

Security

  • Security scanPassed, 95 of 100Pattern checks on the skill's files.
  • Model reviewPassed

Quality evaluation

  • Task evaluationNot runNo evaluation yet. Run one in Skill Studio.

Source

Popularity

Repository stars
9
Repository forks
1
7-day trend score
12

Stars and forks are for the whole GitHub repository, not this skill alone. Not refreshed yet.

Works with

Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.

  • Claude Code
  • Cursor
  • GitHub Copilot
  • Windsurf
  • Codex
  • Gemini CLI
  • Cline
  • Amp
  • Roo Code
  • Goose
  • Continue
  • Kilo Code
  • Junie
  • Trae
  • OpenHands
  • Qwen Code
  • AI Agent
  • Tabnine Chat
  • Sourcegraph Cody
  • Amazon Q
  • Firebase Genkit
  • Sweep
  • Devin
  • Phind
  • Mentat
  • Claude Desktop
  • Aider
  • GPT Pilot
  • Plandex
  • bolt.new
  • v0
  • Replit Agent
  • Anse
  • TypingMind
  • BetterChatGPT
  • LibreChat
  • Warp AI
  • Pieces
  • Fig AI
Embed badge
vskill VERIFIED badge
[![vskill VERIFIED](https://verified-skill.com/api/v1/skills/pekral/cursor-rules/laravel-authorization-review/badge)](https://verified-skill.com/skills/pekral/cursor-rules/laravel-authorization-review)

Something wrong with this skill or its page? Tell us.