PHP Security Masterclass
Study material from posts already published on PHP Hub. It is not an assessment of your application and it does not replace an authorized audit.

1. Password Hashing in PHP: password_hash, password_verify and Safe Rehashing
Store PHP passwords safely with password_hash() and password_verify(), upgrade old hashes on login with password_needs_rehash(), and migrate legacy MD5 hashes.

2. Laravel Mass Assignment: Fillable, Guarded and Safe Request Validation
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.

3. Laravel CSRF Protection: Tokens, Exceptions and SPA Pitfalls
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.

4. XSS Prevention in Laravel Blade: {{ }}, {!! !!} and Js::from
Prefer Blade {{ }} for any user-supplied text, never dump raw input with {!! !!}, use Js::from for JSON in scripts, and leave @{{ }} for frontend frameworks.

5. SQL Injection in Laravel: Raw Queries, Bindings and Safe ORDER BY
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.
- Critical
6. PHP2Shell: two critical PHP core RCE flaws fixed in 8.5.12 / 8.4.27 / 8.3.36 / 8.2.35
On 21 Oct 2026 the PHP project shipped emergency security releases fixing two vulnerabilities in PHP itself (not in any framework or plugin). Both can allow unauthenticated remote code execution.…
- Critical
7. PHP security this week (26 Oct – 2 Nov 2026)
Five items worth a look this week, from official sources only (checked 2 Nov 2026 against NVD, the CISA KEV catalog and GitHub advisories). One is urgent (PHP itself); the rest are routine…

8. How We Patched Our Own Site: Clearing 5 npm Advisories with an Astro 7 Upgrade
npm audit flagged 5 advisories (1 critical) on PHP Hub. How we upgraded Astro 5.18.2 to 7.4.5, moved to Node 22 and proved nothing broke.
A case study about this site’s own dependency upgrade.
Questions from the published lessons
Questions are taken from published PHP Hub lessons. This does not grade a certification, and the answers are checked in your browser.