I am trying to fix my headers. I see two errors when checking the network requests as I visit my page:
1) X-FRAME-OPTIONS: SAMEORIGIN
is shown twice:
Cache-Control:no-cache
Connection:Keep-Alive
Content-Encoding:gzip
Content-Type:text/html; charset=UTF-8
Date:Wed, 04 Oct 2017 12:58:30 GMT
Keep-Alive:timeout=3, max=1000
Server:Apache
Set-Cookie:laravel_session=eifQ%3D%3D; expires=Wed, 04-Oct-2017 14:58:30 GMT; Max-Age=7200; path=/; secure; httponly
Set-Cookie:XSRF-TOKEN=n0%3D; expires=Wed, 04-Oct-2017 14:58:30 GMT; Max-Age=7200; path=/
Transfer-Encoding:chunked
X-CDN:Incapsula
X-Frame-Options:SAMEORIGIN * <-------------- HERE
X-Frame-Options:SAMEORIGIN * <-------------- HERE
X-Iinfo:7-6626704-6651371 NNNN CT(0 0 0) RT(1507121414380 495318) q(0 1 1 -1) r(2 2) U16
X-XSS-Protection:%E2%80%9C1;mode=block%E2%80%9D <-------- Strange Encoding here...
2) I can see the following error on the console for X-XSS-PROTECTION
:
Error parsing header X-XSS-Protection: â1;mode=blockâ: expected 0 or 1 at character position 0. The default protections will be applied.
I am using Laravel 5.0. The FrameGuard.php
middleware is not active by default since Laravel 4.2, but you have the option to enable it if needed. When it's disabled, I see the above errors and I really can't understand why, so my first though was to overwrite those headers by actually using that middleware.
When I add the Illuminate\Http\Middleware\FrameGuard.php
middleware, which contains the below code, nothing seems to change:
public function handle($request, Closure $next)
{
$response = $next($request);
$response->headers->set('X-XSS-Protection', '1; mode=block');
$response->headers->set('Content-Type','text/html; charset=UTF-8');
$response->headers->set('X-Frame-Options', 'SAMEORIGIN', true);
return $response;
}
I also use Socialite which provides Facebook authentication. Is there a chance that it modifies any headers?
decodeURIComponent("%E2%80%9C1")="“1"
. This means the error probably has been introduce by you only somewhere by using a smart quote instead of a normal quote. Did you copy past some code from web or a word doc? Also you can detect which file has the smart quote usinggrep -r "“" .
– Globetrotter