Skip to content
Back to skills

Laravel Owasp Security

ASecurity

OWASP Top 10 security audit and secure coding guidelines for Laravel + React/Inertia.js applications. Use when auditing for vulnerabilities ("run OWASP audit", "security review", "check my app security") or writing secure Laravel code involving auth, payments, file uploads, or API design. Triggers on security-related tasks, payment handling, authentication, or any request to audit a Laravel codebase. Not for Laravel for Rust apps (laravel-rust crate).

  • 2 stars
  • 0 votes
  • 0 copies
  • 0 views
  • Added December 2, 2026
developmentjavascripttypescriptrustgojavaphpshellsqlreactgit

Works with

  • cli
  • api

Security analysis

A100/100

Pro scans all 17 files and shows the line behind each finding

Scanned December 2, 2026

npx -y skills add airshell/laravel-php-to-rust --skill laravel-owasp-security --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Laravel Owasp Security?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Laravel Owasp Security
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/airshell-laravel-owasp-security/badge)](https://www.skillsdirectory.com/skills/airshell-laravel-owasp-security)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: laravel-owasp-security
description: OWASP Top 10 security audit and secure coding guidelines for Laravel + React/Inertia.js applications. Use when auditing for vulnerabilities ("run OWASP audit", "security review", "check my app security") or writing secure Laravel code involving auth, payments, file uploads, or API design. Triggers on security-related tasks, payment handling, authentication, or any request to audit a Laravel codebase. Not for Laravel for Rust apps (laravel-rust crate).
license: MIT
metadata:
  author: airshell
  version: "1.2.2"
  laravelVersion: "13.x"
  phpVersion: "8.3+"
---

# Laravel OWASP Security

Dual-purpose security skill for Laravel 13 + React/Inertia.js applications. Run an OWASP Top 10:2025 audit against a codebase, or use as a secure coding reference when building features.

**Not for Laravel for Rust.** If the project is a Laravel for Rust app (its `Cargo.toml` depends on the `laravel-rust` crate), neither mode applies: the checklist assumes a Laravel PHP backend. Say so and stop. To audit the app, use the `laravel-rust-audit` skill; to write code, use the agent skills the app ships in `.agents/skills/` and the version-matched docs bundled with the crate.

## Modes

- **Guidance (default):** questions, writing secure code, reviewing one feature. Use the relevant rule files; do not produce a full audit report.
- **Audit:** only when asked to audit, pen-test or security-review the codebase (or a named part of it). Follow the steps below and report with verdicts, not PASS/FAIL.

## How to Audit

### Step 1: Detect Stack

Check if the project uses React + Inertia.js by looking for:
- `app/Http/Middleware/HandleInertiaRequests.php` exists
- `resources/js/` contains `.tsx` or `.jsx` files
- `inertiajs/inertia-laravel` in `composer.json`
- `@inertiajs/react` in `package.json`

**If detected**, state at the top of the report:
> "React + Inertia.js detected — Laravel OWASP checklist AND React/Inertia security checks will both be applied."

**If not detected**, state:
> "No React/Inertia.js detected — applying Laravel OWASP checklist only."

**If only the server side is present** (`inertiajs/inertia-laravel` and `HandleInertiaRequests`, but no React files), state that, apply the server-side Inertia checks (R2 props, R3 CSRF server part), and list R1, R5 and the client part of R3 under Coverage as not reviewed.

### Step 2: Determine Scope

- If arguments provided (`$ARGUMENTS`): review only those files or features
- If no arguments: review the entire codebase

### Step 3: Map the Trust Boundaries

Before hunting, list what an attacker can reach and who they can be:
- Routes and their middleware: `php artisan route:list --json` (guest, `auth`, roles, `signed`, `throttle`), including vendor and dev-package routes. A route that exists only with `APP_ENV=local` or dev dependencies installed is **Needs validation** (check production `APP_ENV` and `composer install --no-dev`)
- Guards and actors: guests, customers, staff, admins, API tokens, other tenants
- Authorization points: policies, gates, Form Request `authorize()`, global scopes, `scopeBindings()`
- Inputs beyond forms: webhooks, uploads, imports, queued payloads, Inertia partial reloads
- Data leaving the server: Inertia shared props and page props, API Resources, exports
- Controls outside the repository (production `.env`, web server, proxy/CDN): see `audit-outside-repo-controls`

### Step 4: Hunt With the Checklist

Use the OWASP checklist below as a map of where to look. A failed checklist item is a **lead**, not a finding. Follow each lead to a concrete path an actor can use.

### Step 5: Gate, Prove, Disprove

- Pass every candidate through `audit-candidate-gate`: actor, input, control, boundary, result
- Prove it with a Pest feature test on the test database (`audit-prove-with-tests`). Never test against production, staging data or real accounts
- Try to disprove it (global scopes, middleware in `bootstrap/app.php`, policies registered elsewhere). When another agent is available, give it each Confirmed candidate with its file paths and proof test and ask it to break the claim; keep only what survives. This step is recommended, not required; say in the report whether it was done
- Never reproduce secrets, API keys, tokens or `.env` values from the code in the report

### Step 6: Report With Verdicts

Classify each item with `audit-verdicts-severity`: **Confirmed** (with severity), **Needs validation** (missing fact and how to check it, no severity), **Hardening** (no severity). List checklist areas that were reviewed with nothing found as coverage, not as findings.

---

## OWASP Top 10:2025 Checklist

> Numbering follows the [OWASP Top 10:2025](https://top10.owasp.org/2025/). Changes from 2021: SSRF (CWE-918) is rolled into A01, where CSRF (CWE-352) and open redirect (CWE-601) are also mapped; Security Misconfiguration moves up to A02; Vulnerable & Outdated Components grew into A03 Software Supply Chain Failures; A10 is the new Mishandling of Exceptional Conditions.

### 1. Broken Access Control (A01:2025)

**Authorization:**
- [ ] Middleware protects all route groups by role (`auth`, `role:admin`, etc.)
- [ ] Resource queries scoped to authenticated user — `->where('user_id', auth()->id())`
- [ ] No direct object reference without ownership check
- [ ] Gates and Policies used to authorize resource access
- [ ] Frontend role checks are mirrored server-side — never rely on React UI checks alone

**CSRF (CWE-352):**
- [ ] CSRF middleware (`PreventRequestForgery` in Laravel 13; `VerifyCsrfToken` / `ValidateCsrfToken` are aliases of it) active in the web group
- [ ] Only stateless routes (webhooks, external callbacks) are excluded from CSRF
- [ ] `@csrf` directive used in all non-Inertia POST forms
- [ ] Excluded routes in `validateCsrfTokens(except: [...])` are justified

**SSRF (CWE-918):**
- [ ] No `Http::get($request->input('url'))` with unvalidated URLs
- [ ] User-supplied URLs validated against an allowlist or scheme check
- [ ] Internal network addresses blocked from user-supplied URLs

**Open Redirect (CWE-601):**
- [ ] No `redirect($request->input('url'))` with unvalidated URLs

### 2. Security Misconfiguration (A02:2025)

- [ ] `APP_DEBUG=false` in production — no stack traces shown to users
- [ ] `.env` is in `.gitignore` and never committed
- [ ] Database uses a restricted user — not root/admin — in production
- [ ] `storage/` and `bootstrap/cache/` have correct permissions (not world-writable)
- [ ] `APP_KEY` is set and unique per environment
- [ ] CORS `allowed_origins` is not `['*']` for authenticated API routes
- [ ] Security headers set (see Additional Checks)

**Cookies:**
- [ ] `http_only = true` in `config/session.php`
- [ ] `secure = true` or `null` (auto for HTTPS) in `config/session.php`
- [ ] `same_site = lax` or `strict` in `config/session.php`
- [ ] `EncryptCookies` middleware is in the web group

### 3. Software Supply Chain Failures (A03:2025)

- [ ] `composer audit` passes with no known CVEs
- [ ] `npm audit` passes with no known CVEs
- [ ] Laravel framework is on a supported version
- [ ] `composer.lock` and the npm lock file are committed, so direct and transitive dependencies are pinned and audited
- [ ] Packages come only from official registries (Packagist, npm) — no copied vendor code from unknown sources
- [ ] CI/CD secrets and deploy keys are scoped and not readable by untrusted pull requests

### 4. Cryptographic Failures (A04:2025)

- [ ] Passwords hashed with `Hash::make()` or `'hashed'` Eloquent cast — never stored as plaintext
- [ ] No MD5 or SHA1 used for password hashing
- [ ] Sensitive fields (API keys, secrets) encrypted with `Crypt::encryptString()` or `'encrypted'` Eloquent cast
- [ ] `APP_KEY` is long, random, and unique per environment
- [ ] Signed URLs (`URL::signedRoute()`) used for sensitive one-time actions (password reset, email verify)

### 5. Injection (A05:2025)

**SQL & Command Injection:**
- [ ] No string concatenation in `whereRaw()`, `selectRaw()`, `orderByRaw()` — use `?` bindings
- [ ] Column names never derived from user input without a whitelist
- [ ] No `exec()`, `shell_exec()`, `system()`, `passthru()` with user input

**XSS — Blade & React:**
- [ ] No `{!! $userInput !!}` in Blade templates with untrusted data
- [ ] `{{ }}` used for all user-supplied Blade output
- [ ] No `dangerouslySetInnerHTML` in React without `DOMPurify.sanitize()` first
- [ ] `href` and `src` attributes not set from unvalidated user input
- [ ] No `eval()`, `new Function()`, or `setTimeout(string)` with user-controlled strings

### 6. Insecure Design (A06:2025)

- [ ] Business logic enforced server-side — prices, totals, and discounts never trusted from client input
- [ ] Sensitive operations require secondary confirmation (e.g. password re-entry for account deletion)
- [ ] No mass action endpoints without per-item authorization check
- [ ] Admin-only features isolated behind separate middleware — not just hidden in the UI
- [ ] Payment amounts and order states calculated server-side, not passed as form inputs

### 7. Authentication Failures (A07:2025)

- [ ] Using Laravel Breeze, Fortify, or Jetstream — not custom-rolled auth
- [ ] Passwords hashed with bcrypt or argon2 (Laravel default)
- [ ] Login route rate limited — `throttle` middleware or `RateLimiter` in `LoginRequest`
- [ ] Password reset and email verification routes rate limited
- [ ] Payment and sensitive action routes have appropriate rate limits
- [ ] `session()->regenerate()` called after successful login (session fixation)
- [ ] `session()->invalidate()` called on logout
- [ ] Session `lifetime` is a reasonable value (15–30 min recommended for most apps)
- [ ] Session cookie `domain = null` unless subdomains are needed

### 8. Software or Data Integrity Failures (A08:2025)

**Mass Assignment (CWE-915):**
- [ ] No `$request->all()` passed directly to `create()`, `fill()`, or `update()`
- [ ] No `forceFill()` or `forceCreate()` with unvalidated user input
- [ ] Models define `$fillable` explicitly — not `$guarded = []`
- [ ] Controllers use `$request->validated()` for mass operations

**Deserialization & Untrusted Code:**
- [ ] No `unserialize($request->input(...))`
- [ ] No `eval($request->input(...))`
- [ ] No `extract($request->all())`
- [ ] External CDN scripts use Subresource Integrity (`integrity="sha384-..."`)
- [ ] Webhooks verified by signature, not trusted on payload alone

### 9. Security Logging and Alerting Failures (A09:2025)

- [ ] Failed login attempts logged with IP and identifier
- [ ] Payment failures and exceptions logged
- [ ] Log entries do not contain raw passwords or secrets
- [ ] Monitoring in place (Laravel Telescope, Sentry, or similar) and it alerts someone — logs alone are not enough

### 10. Mishandling of Exceptional Conditions (A10:2025)

- [ ] Error responses never show exception messages, SQL, or stack traces to users (CWE-209)
- [ ] Multi-step money or stock changes run inside `DB::transaction()` so a failure rolls back every step (fail closed)
- [ ] `catch` blocks never grant access or continue as success — authorization and payment checks fail closed (CWE-636)
- [ ] Exceptions from external calls (`Http::`, queues, payment APIs) are caught, reported, and turned into a safe response — not swallowed
- [ ] A global handler (`withExceptions()` in `bootstrap/app.php`) reports unexpected exceptions; repeated errors are monitored
- [ ] Missing or malformed parameters are rejected by validation, not left to fail deeper in the code

---

## Additional Checks

> Not part of the OWASP Top 10 but critical for Laravel applications.

### File Uploads

- [ ] File uploads validate `mimes:`, `max:` — filenames never derived from raw user input

### Security Headers

- [ ] `Content-Security-Policy` set — with nonces (`Vite::useCspNonce()`) if possible
- [ ] `X-Frame-Options` set
- [ ] `X-Content-Type-Options` set
- [ ] `Strict-Transport-Security` set for HTTPS
- [ ] `Referrer-Policy` set
- [ ] `Permissions-Policy` set

---

## React + Inertia.js Checks

> Only run if React + Inertia.js detected in Step 1.

### R1. XSS in React Components

- [ ] No `dangerouslySetInnerHTML={{ __html: userInput }}` without `DOMPurify.sanitize()` first
- [ ] `href` and `src` attributes not set from unvalidated user input — `javascript:` URLs execute scripts
- [ ] No `eval()`, `new Function()`, or `setTimeout(string)` with user-controlled strings
- [ ] Links from user input validate scheme (`https://` or `http://` only)

### R2. Inertia.js Data Exposure (Critical)

- [ ] `HandleInertiaRequests::share()` does NOT expose passwords, tokens, or internal-only flags
- [ ] Controllers use `->only([...])` or API Resources — not raw model `toArray()`
- [ ] All Inertia props are treated as public — visible in View Source on initial load (Inertia v3: `<script type="application/json">`; v2: `data-page` attribute)
- [ ] Payment secret keys and admin-only credentials are never passed as Inertia props
- [ ] History Encryption (`encryptHistory`, v2+) enabled for pages with sensitive data, and history cleared on logout

### R3. CSRF in Inertia.js

- [ ] Inertia `X-XSRF-TOKEN` header not disabled
- [ ] Non-visit requests use `useHttp` (Inertia v3 no longer ships Axios); custom `fetch` or app-installed Axios calls send `X-XSRF-TOKEN` themselves
- [ ] Webhook/callback routes are the ONLY CSRF-excluded routes

### R4. Authentication State in React

- [ ] `auth.user` Inertia prop excludes password hash, remember tokens, and 2FA secrets
- [ ] Role/permission checks enforced server-side — React checks are UI-only
- [ ] `auth.user` contains only fields the UI actually needs

### R5. Sensitive Data in Browser

- [ ] No API keys or secrets hardcoded in React components or TypeScript files
- [ ] No sensitive data in `localStorage` or `sessionStorage` — use HttpOnly cookies
- [ ] `VITE_*` env vars contain no secrets — they are public by design

### R6. Dependency Security

- [ ] `npm audit` passes with no high/critical CVEs in React or Inertia packages
- [ ] React is on a supported version
- [ ] Third-party component libraries reviewed for known CVEs

---

## Output Format

Structure the audit report as:

```
## Laravel OWASP Security Audit Report

> React + Inertia.js detected — Laravel OWASP checklist AND React/Inertia security checks will both be applied.
> Scope: whole codebase at <commit> (or "not a git repository"). Not covered: production configuration (see Needs validation).
> Proof: <N> security tests; the failing ones are the proofs. Independent disproval: done / not done.

### Confirmed
1. **HIGH** — Customer reads another customer's order (A01:2025)
   - Actor and input: signed-in customer, `{order}` in `GET /orders/{order}`
   - Missing control: `OrderController@show` has no policy check (`app/Http/Controllers/OrderController.php:31`)
   - Result: another customer's order and address returned (`tests/Feature/Security/OrderOwnershipTest.php`)
   - Fix: `Gate::authorize('view', $order)` with `OrderPolicy::view()`; keep the test as a regression test

### Needs validation (no severity)
1. Debug mode in production — `config/app.php` reads `APP_DEBUG` from the environment.
   Check: production `APP_DEBUG=false`, and a staging error page shows no stack trace.

### Hardening (no severity)
1. No `Content-Security-Policy` header in the app; no user-supplied HTML is rendered today.

### Coverage
- Reviewed with nothing found: A04 Cryptographic Failures, A05 Injection, R1 XSS, R3 CSRF
- Not reviewed: <areas>, and why

### Recommended Commands
composer audit
npm audit          (needs package-lock.json; without one, note it under Hardening and list npm under Coverage as not reviewed)
```

---

## When to Apply for Guidance

Reference the rule files when:
- Implementing authentication or password handling
- Building payment or webhook integrations
- Writing file upload or download logic
- Designing admin or role-based access control
- Building API endpoints with user-supplied input
- Using `dangerouslySetInnerHTML` in React components
- Passing data from Laravel controllers to Inertia props

## Rule Categories by Priority

| Priority | Category | Impact | Rule File |
|----------|----------|--------|-----------|
| 1 | Broken Access Control (A01) | CRITICAL | `sec-broken-access-control` |
| 2 | Cryptographic Failures (A04) | CRITICAL | `sec-cryptographic-failures` |
| 3 | Injection Prevention (A05, A08) | CRITICAL | `sec-injection-prevention` |
| 4 | XSS & React/Inertia (A05) | HIGH | `sec-xss-react-inertia` |
| 5 | CSRF Protection (A01) | HIGH | `sec-csrf-protection` |
| 6 | Security Misconfiguration (A02) | HIGH | `sec-security-misconfiguration` |
| 7 | Authentication & Rate Limiting (A07) | HIGH | `sec-authentication-rate-limiting` |
| 8 | Inertia Data Exposure (R2) | HIGH | `sec-inertia-data-exposure` |
| 9 | Audit Method | CRITICAL | `audit-candidate-gate`, `audit-verdicts-severity`, `audit-outside-repo-controls`, `audit-prove-with-tests` |

## Quick Reference

### 1. Broken Access Control (CRITICAL)
- `sec-broken-access-control` — Middleware, ownership checks, policies, scoped queries

### 2. Cryptographic Failures (CRITICAL)
- `sec-cryptographic-failures` — Password hashing, encrypted casts, signed URLs

### 3. Injection Prevention (CRITICAL)
- `sec-injection-prevention` — SQL injection, mass assignment, raw query bindings

### 4. XSS & React/Inertia (HIGH)
- `sec-xss-react-inertia` — dangerouslySetInnerHTML, DOMPurify, href/src validation

### 5. CSRF Protection (HIGH)
- `sec-csrf-protection` — PreventRequestForgery (VerifyCsrfToken), webhook exclusions, Inertia v3 XSRF header and `useHttp`

### 6. Security Misconfiguration (HIGH)
- `sec-security-misconfiguration` — APP_DEBUG, APP_KEY, security headers, CORS

### 7. Authentication & Rate Limiting (HIGH)
- `sec-authentication-rate-limiting` — Throttle, session regeneration, brute force prevention

### 8. Inertia Data Exposure (HIGH)
- `sec-inertia-data-exposure` — initial page data in View Source, secret props, API Resources

### 9. Audit Method (CRITICAL, audit mode)
- `audit-candidate-gate` — actor, input, control, boundary, result; checklist gaps are leads or hardening
- `audit-verdicts-severity` — Confirmed / Needs validation / Hardening, severity anchors for confirmed only
- `audit-outside-repo-controls` — production `.env`, proxy, CDN and server settings are not guessed from the repo
- `audit-prove-with-tests` — Pest test on the test database, disprove first, fix at the decision point

## How to Use

Read individual rule files for detailed explanations and code examples:

```
rules/sec-broken-access-control.md
rules/sec-cryptographic-failures.md
rules/sec-injection-prevention.md
rules/sec-xss-react-inertia.md
rules/sec-csrf-protection.md
rules/sec-security-misconfiguration.md
rules/sec-authentication-rate-limiting.md
rules/sec-inertia-data-exposure.md
rules/audit-candidate-gate.md
rules/audit-verdicts-severity.md
rules/audit-outside-repo-controls.md
rules/audit-prove-with-tests.md
```

Each rule file contains:
- YAML frontmatter with metadata (title, impact, tags)
- Why it matters in Laravel/React context
- Incorrect code example with explanation
- Correct code example with fix
- Laravel 13 and PHP 8.3+ specific context

## Metadata

- **Version**: 1.2.2
- **Last Updated**: December 2026
- **Rule Count**: 12 rules
- **OWASP Mapping**: Top 10:2025

## Full Compiled Document

For the complete guide with all rules expanded: `AGENTS.md`

Files in this skill

  • AGENTS.md35.8 KB
  • README.md3 KB
  • SKILL.md19.2 KB
  • rules/_sections.md4.4 KB
  • rules/_template.md1.6 KB
  • rules/audit-candidate-gate.md4 KB
  • rules/audit-outside-repo-controls.md3.7 KB
  • rules/audit-prove-with-tests.md4.3 KB
  • rules/audit-verdicts-severity.md4.5 KB
  • rules/sec-authentication-rate-limiting.md6.6 KB
  • rules/sec-broken-access-control.md5.5 KB
  • rules/sec-cryptographic-failures.md4.8 KB
  • rules/sec-csrf-protection.md6.4 KB
  • rules/sec-inertia-data-exposure.md8.1 KB
  • rules/sec-injection-prevention.md6 KB
  • rules/sec-security-misconfiguration.md5.6 KB
  • rules/sec-xss-react-inertia.md5.4 KB

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in development →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.