Unable to load an URL using iFrame because of Content Security Policy - html

<!DOCTYPE html>
<html>
<body>
<iframe src="URL">
<p>Your browser does not support iframes.</p>
</iframe>
</body>
</html>
I am using the above code to load the url inside iFrame and i am getting below error:
Refused to display 'URL' in a frame because an ancestor violates the following Content Security Policy directive: "frame-ancestors https://inteliapp-stage.grymatter.com URL1 URL2 URL3 URL4 URL5 URL6 URL7
http://18.233.166.250 https://18.233.166.250 cdn.jsdelivr.net".
For security reason, i am not able to mention the exact URLs. I want to know what should i add inside meta tag for content security Policy to resolve the problem? If we cant resolve the problem then how we can load the url inside html code.Please help me out. Thanks in advance.

The page you're trying to put in the frame has the policy that's being violated. There isn't any way to weaken CSP rules once sent; so unless you can modify the source of the framed page, there's not much you can do here.
You may be able to use an alternate method, such as doing an HTTP call in the background to fetch the content of that page, and manually insert that content into your page.

Related

x-frame-options header set but can stilll embed in iframe?

The x-frame-options header is confirmed as set to SAMEORIGIN, but when creating a simplistic local HTML file e.g.
<html>
<head>
<title>Clickjack test page</title>
</head>
<body>
<p>Website is vulnerable to clickjacking!</p>
<iframe src="http://www.yoursite.com/sensitive-page" width="500" height="500">
</iframe>
</body>
</html>
and attempting to embed the target page i'm able to do so without issue.
What could be causing this?
Thanks
Some reasons I can think of:
Page is being loaded from the same origin, hence allowed.
"X-Frame-Options" or "SAMEORIGIN" is not spelled correctly and hence ignored.
Content-Security-Policy frame-ancestors directive is more permissive and X-Frame-Options is ignored when it is set. If this is the case it should be blocked in IE which doesn't understand Content-Security-Policy.
Your browser is more lenient with local files.

How to use a heroku app inside a html iframe?

I want to use this heroku app (spring boot) inside an iframe. https://sef-github-leaderboard.herokuapp.com/ but it doesn't work. it says refused to connect. Here's the code.
<!DOCTYPE html>
<html>
<body>
<iframe src="https://sef-github-leaderboard.herokuapp.com/" title="Iframe Example" style="height:500px;width:100%;"></iframe>
</body>
</html>
If you open up devtools, click the Network tab, refresh the page, and click the first item in the waterfall, you'll find that the Content Security Policy header X-Frame-Options is set to DENY on the URL you are seeking to embed. This instructs the browser to disallow loading the page within an iframe. To get around this, you would need to use a forward proxy to strip out the headers.

<iframe> is not working

I'm making a simple html page which is require an <iframe> to show a specific area of the page. I used iframe so many times but this time I don't know what I'm doing wrong...
Please take a look at my code and help me!
HTML
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Iframe Test</title>
</head>
<body>
<iframe src="https://www.secure-booker.com/sorelle/ShopOnline/Products.aspx" width="1000" height="1000" frameborder="0"></iframe>
</body>
</html>
The page you are trying to embed in the iframe blocks itself from being embedded.
You can see this if you open your browser's console (F12) and select the "Console" tab.
Refused to display 'https://www.secure-booker.com/sorelle/ShopOnline/Products.aspx' in a frame because an ancestor violates the following Content Security Policy directive: "frame-ancestors 'self' http://*.sorellechicago.com sorellechicago.com *.sorellechicago.com".
TL;DR: It's not possible.
You are not allowed to iFrame this Website. because they have set the following.
'X-Frame-Options' to 'SAMEORIGIN'.
You can find this from your console.
Refused to display 'https://www.secure-booker.com/sorelle/ShopOnline/Products.aspx' in a frame because an ancestor violates the following Content Security Policy directive: "frame-ancestors 'self' http://*.sorellechicago.com sorellechicago.com *.sorellechicago.com".
How to set this options?
https://developer.mozilla.org/en-US/docs/Web/HTTP/X-Frame-Options
How to set 'X-Frame-Options' on iframe?
X-Frame-Options on apache
One more note (FYI) : AFAIK, there is one more thing called Frame Buster Code to prevent other domain to iFrame the site. Below is the reference URLs:
https://en.wikipedia.org/wiki/Framekiller
https://davidwalsh.name/javascript-framebuster
Frame Buster Buster ... buster code needed
Its a part of Clickjacking as well. Refer the below URL as well.
1. https://en.wikipedia.org/wiki/Clickjacking

Access anchor tag attribute inside iframe

Parent domain: www.parent.com
Iframe domain: www.iframe.com
<html>
<head></head>
<body>
<iframe id="trick" src="www.iframe.com/test">
<html>
<head></head>
<body>
test
</body>
</html>
</body>
</html>
Question: how to access the value of href of anchor tag inside iframe using jquery?
Since they pages appear on different origins:
The page containing the frame needs to listen for a Message event.
The page inside the frame needs to send a message using postMessage.
This, obviously, requires changes on both sites. Explicit co-operation between the sites is required for obvious security reasons (if they aren't obvious, imagine your bank's website being loaded in an iframe by a random site you visited via Google).
Check this link: http://simple.procoding.net/2008/03/21/how-to-access-iframe-in-jquery/
$('#iframeID').contents().find('#someID').html();

Search Engines & iFrame

I have a very basic html, supposingly
<html>
<body>
<iframe src="http://www.google.com">
<p>Your browser does not support iframes.</p>
</iframe>
</body>
</html>
When I render the page with Google/Yahoo as a source address there is no display. This is what I see in firebug
<iframe src="http://www.google.com">
<html>
<head></head>
<body></body>
</html>
</iframe>
If I am doing something wrong please correct else please provide any authentic documentation if search englines have blocked iframes. Would really appreciate.
p.s You can try the above example on W3Schools too.
You cannot bypass it in browsers , they will simply refuse to display websites in iframe that send a
X-Frame-Options header with DENY or SAMEORIGIN . It doesn't even come down to javascript.
For more read on ClickJacking and X-Frame-Options
what google says about iframe, read Here
refer to Avoid iFrames - or link to their content separately...
With javascript you can easily find out if your site is displayed inside a frameset/IFrame or if it is stands alone:
<script type="text/javascript">if(self!=top){/*I am framed*/}</script>
Probably Google has this code in one of its scripts, and when it finds out that its site is inside a foreign frame, it deletes its content.
With the same simple trick a html page can break out of every frame:
<script type="text/javascript">
if(self!=top){
top.location.replace(self.location.href);
}
</script>
If you want to try out this break-free-trick, replace in your code www.google.com with the url of my site: wissen.schoelnast.at (it is in German)