Laravel Security Best Practices
Harden Laravel with Muse: production config, Sanctum and Passport auth, Gates and Policies, Eloquent mass-assignment safety, CSRF, XSS, file uploads, and API security.
- What
- Harden Laravel with Muse: production config, Sanctum and Passport auth, Gates and Policies, Eloquent mass-assignment safety, CSRF, XSS, file uploads, and API security.
- Cost
- Free
- Needs
- none to install. Pure guidance; a Laravel project helps.
- Level
- Beginner
- Install
- Copy the installer prompt below into your Muse — your agent does the rest.
Curated by Skill Harbor: a security hardening guide that makes Muse review a Laravel application against the framework's real security surface. It starts with production configuration (APP_DEBUG off, APP_KEY set and validated at boot, secure session cookies, HTTPS enforcement with correctly scoped trusted proxies), then covers authentication with Sanctum token abilities, Argon2/bcrypt password hashing, strong password rules with breach checking, and session regeneration on login. Authorization covers Gates with a super-admin before() hook, model Policies wired through controllers and Blade, and role middleware. Eloquent security is a highlight: fillable whitelisting instead of open guarded arrays, safe() and validated() over request all(), parameterized whereRaw, and hidden attributes for API responses. CSRF covers the VerifyCsrfToken middleware with careful webhook-only exemptions, XSS covers Blade auto-escaping and the dangerous raw echo with user input, input validation covers FormRequest rules with post-validation sanitization, and API security covers per-endpoint rate limiters, Sanctum versus Passport guidance, and CORS whitelisting. Correction October 26, 2026: the previous example's sanitize_html rule was not a built-in Laravel rule and has been removed upstream; the same example still strips tags after validation, so do not copy the rules() list alone and assume the title is sanitized. File uploads get MIME, size and dimension validation with private-disk storage and signed URLs, and the skill closes with composer audit in CI, secret management, encrypted queue payloads and a security event audit log. By @affaan-m, listed here with credit to its creator. From the affaan-m/ECC repository (MIT). Honest caveats: a checklist is not a pentest; never paste real secrets into a chat while using it; Sanctum versus Passport advice depends on your auth model, decide deliberately. Skill Harbor never reviews the code, review it yourself before use.
Version:
Quick answer
Laravel Security Best Practices is a free Muse skill and security hardening guide that makes Muse review a Laravel application against the framework's real security surface. It starts with production configuration, debug off, app key validated at boot, secure session cookies and HTTPS enforcement, then Sanctum and Passport auth, Gates and Policies, mass-assignment safety, CSRF, XSS and API security.
Install
Copy the install package below, then paste it into Muse🧪 Install ran in our test sandbox · Nov 11, 2026📌 Pinned version: commit 25278e7Step 0, before installing anything: read this install prompt, summarize in a few lines what this build does and what installing it involves, then ask me to confirm before you proceed. Prerequisites: none to install. Pure guidance; a Laravel project helps. Install "Laravel Security Best Practices" for me. It gives my agent @affaan-m's hardening guide for reviewing a Laravel application against the framework's real security surface: production configuration (APP_DEBUG off, APP_KEY set and validated at boot, secure session cookies, HTTPS enforcement), authentication with Sanctum token abilities and strong password rules, Gates and model Policies, Eloquent safety (fillable whitelisting, safe() and validated() over request all(), parameterized whereRaw), CSRF, XSS (Blade auto-escaping, HTMLPurifier helper), input validation with FormRequest rules and post-validation sanitization, API rate limiting, file upload validation, and dependency and secret hygiene, by @affaan-m, from the affaan-m/ECC repository (MIT). Repository: https://raw.githubusercontent.com/affaan-m/ECC/25278e7d7b6cf6e6a4e7a6c8e10f14ff22f0eb5b/skills/laravel-security/SKILL.md Pinned version: install the code at commit 25278e7d7b6cf6e6a4e7a6c8e10f14ff22f0eb5b exactly (Skill Harbor tested this version). Do not substitute a newer version. If this commit is unreachable, stop and tell me. Updated October 26, 2026: Skill Harbor regenerated this install prompt from the current upstream file. The upstream file is otherwise unchanged: the only change since the previous review is one line in the StorePostRequest example. The title rule no longer lists sanitize_html: it is now ['required', 'string', 'max:255']. Upstream states that sanitize_html is not a built-in Laravel rule and the skill never registers it, so a validator using that rule threw BadMethodCallException: the previous example was broken, not stricter. The same example still strips tags after validation (its validated() method applies strip_tags to the title), and the separate HTMLPurifier helper (sanitizeHtml) is unchanged. In practice the title is still stripped in this example, but only by that post-validation step, not by a validation rule. Do not copy the rules() list on its own and assume the title is sanitized: keep the strip_tags step, or add a real, registered sanitization rule, and verify that it runs. 1. Open the skill: https://raw.githubusercontent.com/affaan-m/ECC/25278e7d7b6cf6e6a4e7a6c8e10f14ff22f0eb5b/skills/laravel-security/SKILL.md and copy the full SKILL.md text, then compare it with the fingerprint from Skill Harbor's review of 2026-10-26: - SKILL.md: SHA-256 1300ff41c52cef3f868f651427aa331971c48a53fe1492e0024d0ae0468d3198 If it does not match, it changed since the review: do not install it yet, tell me what you found and let me decide. 2. Safety check: read the SKILL.md text and review it for anything suspicious (unexpected network calls, shell commands, credential harvesting); STOP on any red flag and tell me. Tell me in plain words what the skill does when used, which services it connects to, whether it reads or sends any personal information or keys, and anything that seems unusual. Confirm these points from the file: - This skill is pure guidance: plain-text instructions only. It runs nothing by itself, connects to no service, sends nothing anywhere, and writes no files. Any PHP, artisan, or composer command it shows is an example for you to review and run yourself, never something the skill runs on its own. - The StorePostRequest example now validates the title as ['required', 'string', 'max:255'], with no sanitize_html rule. The same example still strips tags after validation with strip_tags in validated(). The HTMLPurifier helper sanitizeHtml is a separate, unchanged example for content where some HTML is allowed. - No API keys and no account: the skill needs no credentials. Example values in the file (keys, tokens, passwords) are placeholders or redacted examples, never real secrets. Never paste real secrets into a chat. 3. When I say yes, use it as a skill: paste the SKILL.md text into a chat with Muse and add: "Audit this Laravel project against the security checklist: [paste config and key files, with secrets redacted]." 4. Work through the findings: production config, auth, Gates/Policies, Eloquent mass assignment, CSRF, XSS, uploads, API limits. Tip: ask "which three findings are the most dangerous and what is the exact fix for each?" Safety: a skill is plain-text instructions; it runs nothing by itself. Never paste real secrets into a chat. Review generated commands before running them.
Saved to your recent installs. Find it anytime on /connect.
🔒 Security, provenance and what this touches
The install prompt below already includes the vetting steps: your agent follows the community checklist before installing anything with executable code. Want more?
Verification certificate
Dated facts about what was checked for this listing, and how. This is not a safety certification.
- Pinned version
- 25278e7 · 2026-10-26
- Sandbox install test
- Install ran in our test sandbox · Nov 11, 2026
- Creator identity
- Not verified
- Fingerprint watch
- Last checked · Nov 21, 2026 : no change detected in the files linked by this install prompt
- Install prompt analysis
- 2026-10-13 : No commands, network calls, packages, file writes or API keys detected.
Skill Harbor never reviews the code of a listed skill. These are dated facts about the install prompt and our install test, not a safety certification. Review a skill yourself before you install it. How we verify
Questions
How do I install a skill?
Every product page includes a copy-paste install prompt. Paste it into your Muse and it sets the skill up for you — no manual configuration.
Where does my money go?
Straight to the seller. Skill Harbor never processes payments: checkout happens on the seller’s own page, usually Stripe.
What does the ✓ next to a creator’s name mean?
It means we confirmed the identity of the person behind the listing. It says nothing about the code itself — always check a skill before installing it.