# Clickjacking

## Theory

Lots of websites allow to browsers to render them in a [`<frame>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/frame), [`<iframe>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/iframe), [`<embed>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/embed) or [`<object>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/object). This allows attackers to "load" the website in a transparent layer and trick users into thinking they are browsing the legitimate website. This allows attackers to "hijack" their clicks and make them do something else ([Twitter worm](https://shiflett.org/blog/2009/twitter-dont-click-exploit), [Facebook likes](https://www.netsparker.com/blog/web-security/clickjacking-attack-on-facebook-how-tiny-attribute-save-corporation/)).

[HTTP security headers](/web/config/http-headers.md) like XFO (`X-Frame-Options`) and CSP (`Content-Security-Policy`) mitigate clickjacking attacks.

## Practice

![(left) vulnerable | not vulnerable (right)](/files/HLfrmfK7IoYHXF50EpQn)

The following HTML code can be used in a browser to attempt a clickjacking on a target URL.

{% code title="clickjacking.html" %}

```markup
<html>
    <head>
        <title>Clickjacking / framing test</title>
    ​</head>
    <body>
        <h1>Test a page for clickjacking/framing vulnerability</h1>
        <p>Enter the URL to frame:</p>
        <input id="url" type="text" value="http://TARGET.com"></input>
        <button id="submit-test" onclick='document.getElementById("iframe").src=document.getElementById("url").value'>Test it!</button>
        <br />
        <br />
        <hr>
        <br />
        <iframe src="about:blank" id="iframe" width="100%" height="75%"></iframe>
    </body>
</html>
```

{% endcode %}

## Resources

{% embed url="<https://owasp.org/www-community/attacks/Clickjacking>" %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://legacy.thehacker.recipes/web/config/http-headers/clickjacking.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
