laravel-security

Implements Laravel security practices for authentication, validation, CSRF, uploads, and rate limiting.

1|Updated Oct 11, 2025
One-click install
npx skills add https://github.com/ibytechaos/claude --skill laravel-security-ibytechaos
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: laravel-security
Source: https://github.com/ibytechaos/claude/tree/main/plugins/everything-claude-code/skills/laravel-security
Command: npx skills add https://github.com/ibytechaos/claude --skill laravel-security-ibytechaos

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Laravel applications face common vulnerabilities like SQL injection, XSS, CSRF attacks, mass assignment exploits, and insecure file uploads. This Skill provides concrete, code-level guidance to harden Laravel apps against these threats across authentication, authorization, input handling, and deployment. ## Core Features & Use Cases - Authentication & Authorization: Configure Sanctum/Passport token auth, password hashing rules, policies, gates, and route-level authorization middleware. - Input & Upload Safety: Apply Form Request validation, mass assignment guards, file upload restrictions, and SQL injection prevention via parameter binding. - Production Hardening: Set security headers (CSP, HSTS, X-Frame-Options), configure CORS, rate limiting, signed URLs, encrypted casts, and session/cookie hardening. - Use Case: When building a new API endpoint that accepts file uploads, use this Skill to generate a Form Request with MIME validation, store files on a private disk, enforce authorization via policies, and apply rate limiting. ## Quick Start Review my Laravel controller and routes for security issues and add proper validation, authorization, and rate limiting.

Frequently Asked Questions about laravel-security

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I secure Laravel API endpoints with authentication?

Use Laravel Sanctum or Passport for API token authentication and protect routes with the auth:sanctum middleware. Prefer short-lived tokens with refresh flows, and revoke tokens on logout or account compromise.

How to prevent mass assignment vulnerabilities in Laravel?

Define $fillable or $guarded properties on Eloquent models and avoid Model::unguard(). Prefer DTOs or explicit attribute mapping so request payloads never directly populate model attributes.

Does Laravel protect against CSRF attacks by default?

Yes, the VerifyCsrfToken middleware is enabled by default for web routes. Include @csrf in forms, and for SPA authentication with Sanctum, configure stateful domains in config/sanctum.php.

How do I validate file uploads securely in Laravel?

Use a Form Request with rules for file size, MIME type, and extension, such as 'mimes:pdf' and 'max:5120'. Store uploads on a non-public disk and scan files for malware when required.

What security headers should a Laravel app send?

Add Content-Security-Policy, Strict-Transport-Security, X-Frame-Options, X-Content-Type-Options, and Referrer-Policy headers via middleware. Configure trusted proxies so HTTPS detection and redirects work correctly.

Why is my Laravel rate limiter not blocking brute force logins?

Ensure a named limiter is registered with RateLimiter::for('login') and applied via throttle middleware on auth routes. Use stricter per-minute limits keyed by both IP address and email for login, password reset, and OTP endpoints.