Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Replacing X-Frame-Options with CSP

I am migrating from X-Frame-Options to Content Security Policy to fix the click-jacking vulnerability. My application used to set the SAMEORIGIN policy in hte X-Frame-Options header. What is the equivalent option in Content-Security-Policy?

like image 826
zilcuanu Avatar asked Mar 27 '17 06:03

zilcuanu


People also ask

Does CSP override X-Frame-options?

Chrome ignores X-Frame-Options . Safari 9 and below ignore CSP frame-ancestors .

What is CSP Frame ancestors?

CSP frame-ancestors. The frame-ancestors directive allows you to specify which parent URLs can frame the current resource. Using the frame-ancestors CSP directive we can block or allow a page from being placed within a frame or iframe.

Is X-Frame-options SAMEORIGIN secure?

X-Frame-Options allows content publishers to prevent their own content from being used in an invisible frame by attackers. The DENY option is the most secure, preventing any use of the current page in a frame. More commonly, SAMEORIGIN is used, as it does enable the use of frames, but limits them to the current domain.


1 Answers

frame-ancestors

  • X-Frame-Options: SAMEORIGINContent-Security-Policy: frame-ancestors 'self'

  • X-Frame-Options: DENYContent-Security-Policy: frame-ancestors 'none'

See also https://w3c.github.io/webappsec-csp/#frame-ancestors-and-frame-options

like image 148
sideshowbarker Avatar answered Sep 19 '22 19:09

sideshowbarker