Web

Another Site Is Showing My Website in an Iframe: Clickjacking Protection Guide

Talha Aslan 18 min read

Short answer

What is clickjacking, and why would another site show yours in an iframe?

Clickjacking is when an attacker loads your site inside an invisible or disguised frame on their page and tricks visitors into clicking something on your site without realizing it. The core defense is sending the Content-Security-Policy frame-ancestors and X-Frame-Options headers, which limit which sites may frame your pages.

Keep reading for the full details and examples

One day you notice your website loading inside an unfamiliar domain, as if it were part of that site. Then you see the address bar showing someone else's URL, but the content on screen is yours. That is an iframe embed, and it is also the foundation of an attack called clickjacking. Below we explain what it means, how to protect your site, and how to set the right headers without breaking your own embeds.

That said, not every iframe embed is an attack. Sometimes a directory, an aggregator, or an ad network wants to show your site on its own page. In other cases, the goal is to present your content as their own and earn traffic or ad revenue. Either way, your site appearing on another domain outside your control is not something you want.

Clickjacking, however, is the dangerous version. First, the attacker makes the frame transparent and places a harmless looking button on top. The visitor thinks they are clicking that button, but they actually confirm an action on your site. As a result, a logged in visitor's click can turn into a real action.

Why is it risky when your site gets framed?

In practice, the size of the risk depends on what your site does. For a brochure site, the main harm is brand and content abuse. For sites with logins, carts, checkout, or an admin panel, however, the risk reaches users' accounts and your revenue directly.

These are the types of harm we see most often:

  • Clickjacking actions: invisible clicks on like, follow, settings, or confirm buttons.
  • Phishing: using your real interface and surrounding it with fake login fields.
  • Content and brand abuse: showing your site on their domain wrapped in ads.
  • Polluted analytics: meaningless visits from referrers you do not recognize.
  • Lost trust: visitors seeing your brand on a suspicious address and linking the two.

Therefore you should treat framing protection as a basic security setting on every site, large or small. OWASP covers interface attacks like this as part of the common web application risks. We explain the broader picture in our OWASP Top 10 guide.

How can you tell your site is being shown in an iframe?

Usually you find out by accident, because nobody watches for it. A customer sends a strange link, or you spot your own content under an unknown domain in search results. Still, regular checks help you catch it sooner.

  1. Review the referral report in your analytics tool. Visits from unknown domains that never browse further stand out.
  2. Check the referrer field in your server access log. Requests made from inside a frame often carry the framing site's address.
  3. Open the suspicious address in a browser and search the elements panel in developer tools for an iframe tag. Then check whether its source is your site.
  4. Search for your brand plus a unique sentence from your site. If identical content appears on another domain, it may be a copy rather than a frame.

The last step draws an important line. Put simply, a frame pulls your content live from your server. In a copy, someone has moved your content to another server. The headers below stop frames, but they do not stop copies.

Which pages face the highest clickjacking risk?

Also, not every page carries the same risk. Clickjacking is most dangerous on pages where one click triggers an action. So once protection is in place, verify these pages first.

  • Login and account settings: changing email, resetting passwords, notification preferences.
  • Cart and checkout steps: adding items, confirming addresses, placing orders.
  • Admin panels: privileged actions like deleting content, adding users, or installing plugins.
  • Consent and permission screens: marketing consent, cookie choices, linked account approvals.
  • Form submissions: quote, booking, and application forms.

On purely informational pages, clickjacking is hard to turn into an action, but brand abuse remains. Therefore the healthiest approach is to apply the header site wide and keep an explicit allowlist for pages that genuinely need framing. In addition, OWASP advises against relying on headers alone for sensitive actions and recommends server side confirmation steps.

Is it a frame, a copy, or a redirect?

To pick the right fix, first be clear about what you are seeing. This table helps you separate the three situations people confuse most often.

ObservationMost likelyRight fix
Loads on another domain and changes instantly when you update your siteAn iframe embedframe-ancestors and X-Frame-Options headers
Loads on another domain, but your updates never appear thereA content copy or proxy mirrorCopyright notice, source checks, legal help if needed
Visiting your own site sends you elsewhereRedirect malwareMalware cleanup and a security review
No visible frame, but odd referrers in analyticsA hidden frame or fake trafficSet the headers and watch your logs
Your own checkout or campaign page cannot show your siteHeaders set too strictlyFix the allowlist

Above all, it is easiest to settle this on the day you build the site. With our web design services, we set up a clean server configuration from the start, which reduces the need for later patches. For copies and mirrors, our guide on what to do when a scraper site outranks you walks you through DMCA removal. If your own site sends you to another address, the problem is not a frame but likely redirect malware.

What is X-Frame-Options and what values does it accept?

X-Frame-Options is an older but still common HTTP response header. Specifically, it tells the browser whether your page may appear inside a frame. According to the MDN X-Frame-Options reference, it has two valid values:

  • DENY: the browser will not load the page in any frame, including frames on your own site.
  • SAMEORIGIN: the browser loads the page only if all ancestor frames share your origin.

A third value, ALLOW-FROM, is obsolete. MDN notes that modern browsers ignore the entire header when they see it. So if you write ALLOW-FROM to permit one specific site, you effectively have no protection at all.

Also, setting this header with an HTML meta tag does nothing. MDN is clear here: the browser enforces X-Frame-Options only when it arrives as an HTTP response header. Therefore you need to configure it at the server, hosting panel, or CDN level.

What is frame-ancestors, and how does it differ from X-Frame-Options?

frame-ancestors is a directive of the Content-Security-Policy (CSP) header. It defines which parent sites may frame your page. According to the MDN frame-ancestors reference, it accepts 'none', which allows no site, 'self', which allows only your own origin, and host sources you list one by one.

Its biggest advantage over X-Frame-Options is flexibility, because it accepts host lists. For example, you can allow your own site and a partner's domain at the same time. In addition, frame-ancestors checks every ancestor in a nested chain. If any ancestor does not match, the browser cancels the load.

Still, two details matter. First, frame-ancestors does not fall back to default-src. Even with default-src 'none' in your CSP, other sites can frame your page unless you set frame-ancestors. Second, frame-ancestors does not work in a meta tag either; it must be an HTTP header. The OWASP Clickjacking Defense Cheat Sheet also recommends using both headers and keeping X-Frame-Options for older browsers.

Which one should you use: comparison table

In practice we recommend sending both headers. According to OWASP, the specification gives frame-ancestors precedence over X-Frame-Options, while older browsers may understand only X-Frame-Options. This table sums up the differences.

FeatureX-Frame-OptionsCSP frame-ancestors
Allow no siteDENY'none'
Allow only your own siteSAMEORIGIN'self'
Allow specific external sitesNot possible (ALLOW-FROM is obsolete)List the hosts
Nested frame checksAll ancestors must share your originEvery ancestor in the chain is checked
Works in a meta tagNoNo
Older browser supportBroadMore limited

In short, if you only want to allow your own site, frame-ancestors 'self' together with SAMEORIGIN is the simplest and safest choice. If you need to allow an external site, use the frame-ancestors list and review your X-Frame-Options value accordingly.

How do you add clickjacking protection with Apache and .htaccess?

In practice, most shared hosting runs Apache or an Apache compatible server, so you configure this in the .htaccess file at your site root. Adding headers requires the headers module on the server. It is enabled on most hosts; if you are unsure, ask your provider.

Following MDN's example, this line sets SAMEORIGIN for all pages: Header always set X-Frame-Options "SAMEORIGIN". Next to it, you can add this line for the CSP directive: Header always set Content-Security-Policy "frame-ancestors 'self'".

Then keep these points in mind:

  • If your site already sends a Content-Security-Policy header, add frame-ancestors to the existing policy instead of adding a second header.
  • Back up .htaccess before editing. A typo can take the whole site down.
  • Systems like WordPress manage part of .htaccess themselves. Write your lines outside that block.
  • Clear caches afterward and confirm the header actually goes out.

Also, testing the change on a staging copy first is always safer. Our guide to staging sites explains how to set one up.

How do you add X-Frame-Options and frame-ancestors in Nginx?

On Nginx servers you make this change in the site configuration file. Following MDN's example, you can add add_header X-Frame-Options SAMEORIGIN always; to the http, server, or location block. For CSP, you write add_header Content-Security-Policy "frame-ancestors 'self'" always; in the same way.

However, there is one detail people often miss. Nginx add_header directives do not always pass from a parent block to a child block. If you define another add_header in a location block, the parent's headers can disappear for that location. So check that the headers really go out on every important location.

After that, test the configuration and reload the server. We explain Nginx configuration structure and block logic in our guide on installing Nginx and configuring server blocks. If you have no server access, look for a response header option in your hosting panel or CDN.

How do you set clickjacking protection on WordPress and hosted platforms?

On WordPress, for example, you have two routes: a server level setting in .htaccess or Nginx, or a plugin that adds security headers. The server level is more reliable, because protection disappears if someone deactivates the plugin. If you use a plugin, verify the header from outside the site.

On Shopify, Wix, and similar hosted platforms, you usually have no direct access to server headers. Some of these platforms send their own security headers automatically. To see what goes out, open the network tab in browser developer tools, select the page request, and read the response headers.

If you use a CDN or firewall, adding headers at that layer is also an option. OWASP recommends setting the header centrally on all responses that contain HTML, rather than page by page. Per page setup is error prone, and proxies can silently strip headers. We explain the role of firewalls in front of your server in our article on ModSecurity and WAF basics.

How do you protect your site without breaking your own embeds?

The most common problem is blocking a frame you actually need. First, get one distinction straight: these headers only control whether others can frame your pages. In other words, YouTube videos, maps, or forms you embed on your site stay unaffected. The provider's own headers govern those.

Specifically, the change can affect these situations:

  • Showing a page from your main site on one of your subdomains, such as a store or booking subdomain.
  • Showing your form or calculator in a frame on a partner's site.
  • Your CMS preview screen or a page builder's editing view.
  • A payment or campaign provider displaying your page inside its own screen.

In these cases 'self' alone is not enough. Add each domain you want to allow to the frame-ancestors list. Avoid broad wildcards. If you are curious about the speed impact of outside embeds, see our article on whether embedding Google Maps slows down a website.

Does 'self' cover your subdomains too?

No, it does not, and this detail causes many mistakes. An origin is the combination of scheme, host, and port. So your www address, a subdomain such as shop or booking, and the http and https versions all count as different origins to the browser. So when you write 'self' in frame-ancestors, you allow only the page's own origin.

For example, if you frame a form from your main site on a campaign subdomain, you must add that subdomain to the list separately. SAMEORIGIN does not cover subdomains either. Therefore, before you set up clickjacking protection, list every domain your site uses and note which one frames which. Then you build the allowlist from real usage instead of guesses.

How do you roll out clickjacking protection safely, step by step?

Follow this order to add protection without breaking your own workflows:

  1. Take inventory: list which of your pages are deliberately framed elsewhere.
  2. Decide on a policy: 'self' and SAMEORIGIN if nothing is framed on purpose, an allowlist of domains if something is.
  3. Check existing headers: see whether the site already sends a CSP or X-Frame-Options, and avoid duplicates.
  4. Make the change on staging and test previews, page builders, checkout, and form flows.
  5. Deploy to production and clear caches.
  6. Verify from outside: read the response headers in developer tools.
  7. Check every page type: home, blog, cart, login, and error pages.

Cache layers can delay the change. If the header does not show up right away, follow the checklist in our article on why website changes are not showing.

How can you test clickjacking protection yourself?

Next, you do not need specialist tools to see whether protection works. A simple test shows whether the headers are effective. We recommend repeating it after every significant change.

  1. On your own computer or a test domain, create a blank page that contains only an iframe. Set the iframe source to your site's address.
  2. Open the test page in a browser. If protection works, the frame stays empty or the browser shows an error view.
  3. Look at the developer tools console. The browser should report that it blocked the page because of frame-ancestors or X-Frame-Options.
  4. Repeat the test with your login, cart, and form pages.
  5. If you have an allowed subdomain, test from there too. This time the frame should load.

This test targets only your own site and touches no one else's system. That way you verify clickjacking protection safely and under your own control.

Example scenario: a booking page appearing on a look alike site

For example, picture a service business with an online booking page. A customer sends the owner a link to an unknown domain. When the owner opens it, they see their own booking form wrapped in another site's logo and ads.

Next, the review shows that the foreign page pulls the form live through an iframe. When the business updates its hours, the change appears there instantly. The response headers contain neither X-Frame-Options nor frame-ancestors. Meanwhile, the business's own campaign subdomain also uses the same form in a frame.

In this example scenario, the fix is to list only the main domain and the campaign subdomain in frame-ancestors and set X-Frame-Options to match. After the change, the frame on the foreign page stays blank while the campaign page keeps working. We do not attach a result number. However, you can track the effect in your analytics referral report.

Are JavaScript frame busting scripts enough?

No, they are not. In the past, sites relied on small scripts that moved the page to the top window if it loaded inside a frame. The OWASP clickjacking guide explains that these simple scripts are unreliable and that attackers defeat them in several ways. Examples include double framing or opening the frame in a sandbox that disables JavaScript.

So treat script based methods as an extra layer at most, never as your main defense. The real protection comes from HTTP headers. We see a similar misconception on the content side: disabling right click is also a browser side measure that people bypass easily.

OWASP also mentions SameSite cookies as defense in depth. Browsers do not attach Strict or Lax cookies to cross site frame requests, which helps protect actions that require a session. However, this does not prevent framing itself, so it does not replace the headers.

What are the most common clickjacking protection mistakes?

Specifically, these are the mistakes we run into most often in the field:

  1. Setting X-Frame-Options in an HTML meta tag, which browsers do not enforce.
  2. Writing ALLOW-FROM to permit a specific site, which makes modern browsers ignore the header.
  3. Adding the header only to the homepage and leaving login, cart, and form pages exposed.
  4. Assuming default-src in the CSP also covers frame-ancestors.
  5. Sending two conflicting CSP or X-Frame-Options headers on the same response.
  6. Choosing DENY and breaking your own preview and page builder screens.
  7. Missing that headers vanish in child location blocks on Nginx.
  8. Not checking whether a CDN or proxy strips the headers.

Most of these go unnoticed because nobody verifies the header from outside after setting it. Therefore read the response headers on different page types after every change.

Does clickjacking protection affect SEO or search engine crawling?

No, not when you set it up correctly. Search engine crawlers request your page directly; they do not read it inside a frame. X-Frame-Options and frame-ancestors only decide whether a browser may place your page inside another page. So these headers do not stop crawling or indexing.

Still, consider the indirect effects. For example, a foreign page that frames your site on its own domain may try to promote its address with your content. Once you add clickjacking protection, that page goes blank and cannot use your content. In that sense, protection gives you back control of your content.

User trust is another indirect effect. If visitors never see your brand on a suspicious address, no negative impression forms. In short, security headers are not a ranking tool, but they protect your site's reputation.

Does being framed mean your site was hacked?

Usually not, because framing means an attacker calls your public page inside their own page. It does not mean someone accessed your server, so stay calm. So you do not need to change passwords or clean the server as a first reaction.

However, some signs deserve a separate look. If your own site sends you to an unwanted address, if links or scripts you did not add appear on your pages, or if unknown pages show up in search results, the problem goes beyond framing. In that case, follow the steps in our guide on what to do when your business website got hacked.

In short, framing and a breach are separate problems. You prevent the first with headers, while the second needs a security review. Diagnosing which one you face reduces the risk of panic and the wrong response.

When can you do it yourself, and when should you hand it to an expert?

If you want a simple rule that allows framing only by your own site, and you can edit .htaccess or your hosting panel, you can do this yourself. The two lines above plus the verification steps are enough for most brochure sites.

However, some situations need care. Your site may already have a complex content security policy. Several subdomains may frame each other. Payment and campaign providers may display your pages. Or your stack may have several layers, such as server, CDN, and firewall. In those cases one wrong line can silently break an important flow.

In a setup like that, take inventory first, test on staging next, and go live last. You can run this process with your own team. If you cannot, help from someone who knows the stack protects both your security and your conversion flows.

How do you plan security headers during the website design phase?

On most sites, however, owners add security headers later, after something goes wrong. Yet deciding which pages may appear where is a decision you make during design and setup. Make it early and you manage protection and your own embeds with the same plan.

At Talha Aslan and team, we build on clean server configuration, lean custom code instead of bloated themes and plugin stacks, and documented structure that another developer can take over. As a result, it is clear which layer carries which setting, and adding or changing a security setting brings no surprises.

For a new site, ask the team one question during corporate website design: which pages may be framed elsewhere, and how will you restrict that? If your current site has no clickjacking protection, start with the steps on this page. If the setup is complex, we can review it together.

Frequently Asked Questions

What is clickjacking?
Clickjacking is when an attacker loads your site inside an invisible or disguised frame on their page and tricks visitors into clicking something on your site without realizing it. The visitor thinks they press a harmless button, but they actually confirm an action on your page. The core defense is restricting framing with HTTP headers.
Should I use X-Frame-Options or frame-ancestors?
We recommend using both. frame-ancestors is more flexible, lets you allow specific domains, and according to OWASP takes precedence over X-Frame-Options in the specification. X-Frame-Options still protects users on older browsers. If you only want to allow your own site, the values 'self' and SAMEORIGIN are the simplest and safest choice.
Can I set X-Frame-Options with a meta tag?
No. According to MDN, browsers enforce X-Frame-Options only when it arrives as an HTTP response header; a meta tag has no effect. The same applies to the CSP frame-ancestors directive. So you need to configure it in your server settings, the .htaccess file, your hosting panel, or your CDN.
Will these headers break YouTube videos or maps on my site?
No. These headers only control whether other sites can frame your pages. The behavior of videos, maps, or forms you embed on your site depends on each provider's own headers. What can be affected are your own subdomains, partner sites, and preview screens that show your pages inside a frame on another origin.
How do I know the header is working?
Open the network tab in browser developer tools and look for X-Frame-Options and Content-Security-Policy in the page response headers. Then try framing your page from a test page on another domain. If protection works, the frame stays empty and the console shows a blocking message. Repeat the check on different page types.
If my site is shown in a frame, was I hacked?
Usually not. Framing means someone calls your public page inside their own page, and it does not mean they accessed your server. However, if your own site redirects you elsewhere or you see links you did not add, the problem is deeper. In that case run a separate security review and keep your records.
  • clickjacking
  • X-Frame-Options
  • frame-ancestors
  • iframe
  • Content Security Policy
  • web security
  • web design
Share:
Talha Aslan

Google Partner digital marketing expert. Hands-on with SEO, Google Ads, web design and e-commerce projects since 2012; every post here comes from that experience.

Next project

Get a quote for your project.

Your brief goes straight to Talha Aslan and team: strategy led by Talha, delivery by an experienced team. We reply the same day and send the scope, timeline and price as a written quote within 1 business day.