Laravel security is mostly a set of small habits applied consistently: validate what comes in, escape what goes out, keep secrets out of Git and logs, and keep dependencies current. This page collects every PHP Hub lesson and weekly brief that touches Laravel, grouped by the part of the app you are trying to protect.
The lessons are practical and short. Each one explains the risk, shows the safe pattern in Laravel or plain PHP, and links to official documentation so you can check the details yourself. The weekly briefs track advisories for PHP projects and are fact-checked against the advisory records. New Laravel posts show up here automatically.
Define named Laravel rate limiters with RateLimiter::for() and Limit::perMinute()->by(), attach them with the throttle middleware (HTTP 429 when exceeded), and keep Fortify's default login throttle: 5 attempts per 60 seconds, keyed by username and IP.
Laravel's redirect()->to() returns full URLs like https://evil.example or //evil.example unchanged, so redirect($request->input('next')) is an open redirect. Accept only single-slash local paths (or an explicit host allowlist), reject backslashes and control characters, and fall back to a safe default.
uniqid(), mt_rand() and rand() are not for secrets. Use random_bytes() or random_int() (or Laravel's Str::random, which uses random_bytes), store a hash of the token instead of the token, and compare with hash_equals().
Plain PHP ships with session.use_strict_mode, cookie_httponly and cookie_secure all off. Turn them on, regenerate the ID after login, and in Laravel set SESSION_SECURE_COOKIE and keep the regenerate/invalidate calls in your auth flow.
Store PHP passwords safely with password_hash() and password_verify(), upgrade old hashes on login with password_needs_rehash(), and migrate legacy MD5 hashes.
Laravel published two moderate advisories for laravel/framework on 18 Nov 2026: Rule::exists()/Rule::unique() fluent where() values can be read as predicates, and exists can be bypassed by integer or boolean JSON input on MySQL/MariaDB. Upgrade to 12.73.0 or 13.43.0, add string rules before exists/unique, and keep independent ownership checks.
SSRF happens when your server fetches a URL an attacker chose. Don't pass request input to file_get_contents(), cURL or Laravel's Http::get(). Allow-list the hosts you intend to call, require HTTPS, reject URLs with credentials, and disable redirects.
Treat the client filename, extension and Content-Type as untrusted, detect the type from file contents, store under a generated name on a non-public disk, and never let the web server execute an upload as PHP.
Bind every value (?, named bindings, or the query builder), never interpolate request data into raw SQL, and allow-list column names and sort directions because PDO cannot bind them.
Allow-list model columns, pass only validated input to create() and update(), and make Laravel fail loudly in development when a field is silently dropped.
Prefer Blade {{ }} for any user-supplied text, never dump raw input with {!! !!}, use Js::from for JSON in scripts, and leave @{{ }} for frontend frameworks.
Keep Laravel CSRF on for cookie-auth routes, put tokens in forms and AJAX headers, exclude only true third-party webhooks, and initialize Sanctum SPAs with /sanctum/csrf-cookie.
Laravel's documentation says the .env file should not be committed to source control. Keep APP_KEY and database credentials in the environment, set APP_DEBUG to false in production, and after config:cache only call env() from config files. If you need a file in git, use php artisan env:encrypt and store the decryption key in a password manager.
Laravel signed URLs append an HMAC to the query string so the path and query cannot be altered unnoticed. Prefer URL::temporarySignedRoute() with an expiry, protect the route with the signed middleware, and read parameters with $request->query() because the request body is not signed.
Laravel's Crypt::encryptString() uses OpenSSL AES-256-CBC and signs every value with a MAC. Generate APP_KEY with php artisan key:generate, never commit it, and use APP_PREVIOUS_KEYS when you rotate. In plain PHP, use the sodium extension's documented secretbox API rather than a home-grown cipher.
Never concatenate request input onto a filesystem path. Reject null bytes, backslashes and absolute paths, resolve the result with realpath(), and allow the file only when it stays inside a known base directory. realpath() returns false when the path does not exist, so new files need a parent-directory check.
Do not log $request->all(), Authorization headers, cookies or passwords. Use Laravel's Log facade with a request id from Log::withContext() or shareContext(), and run context arrays through a redaction helper before writing them. Logs are often copied to Slack, files and log vendors — a secret in a log is a secret out of your app.
The PHP manual warns: do not pass untrusted input to unserialize(), regardless of allowed_classes. Unserialization can instantiate objects and run code during autoloading. Prefer json_encode() / json_decode() for data you accept from users, and treat allowed_classes as a hardening step for trusted payloads only.
Five PHP advisories worth a look: Jane OpenAPI codegen RCE, Silverstripe framework RCE, Paymenter (Laravel/Livewire) unauthenticated method call, Contao admin self-grant, and a SimpleSAMLphp SAML2 signature bypass. None is on CISA KEV.
Quiet week in PHP: Laravel concurrency output injection (low), two medium code16/sharp flaws, and a FileGator upload/batch-download pair. None is on CISA KEV.
Run composer audit (and composer audit --locked in CI) against the Packagist advisory API. The command exits 0 when it finds no issues and 1 when packages match a policy, including security advisories, abandoned packages or malware flags. composer update already runs an audit unless you pass --no-audit.