Posts

Showing posts from March, 2025

Clickjacking

Clickjacking Possible (OTG-CLIENT-009)   Clickjacking is a vulnerability that allows an attacker to trick users into clicking something they didn't intend to, potentially causing unauthorized actions on a website. The best way to prevent this in a Laravel project is by setting the X-Frame-Options HTTP header. ✅ Solution: Protect Laravel from Clickjacking You need to configure the response headers to prevent clickjacking attacks. 1️⃣ Add X-Frame-Options in Middleware Laravel provides a built-in middleware to prevent clickjacking. You just need to enable it. Step 1: Open the Middleware file Navigate to: 📂 app/Http/Middleware/TrustHosts.php (Laravel 7+) 📂 app/Http/Middleware/FrameGuard.php (Laravel 5.4 - 6) If the file doesn't exist , create a new middleware: php artisan make:middleware FrameGuard Step 2: Add the following code to prevent clickjacking namespace App\Http\Middleware; use Closure; class FrameGuard { public function handle($request, Closure ...