CSS
hijacking is a type of hijacking that is not very well recognized, but it does have certain risks. Moreover, because it does not necessarily rely on JavaScript
, this makes this type of attack easier to implement.
When visiting a website, attackers can use CSS
to transparently hide the actual page they want you to click on, and then display something else on top of it to induce you to click. Clicking on it will perform certain actions without the user's knowledge, and this is known as ClickJacking.
For example, if we have a forum that we want people to follow, we can construct a phishing page to lure users into clicking. In reality, the page that the attacker wants the user to click on is transparent. If the user is logged into the forum on the web page, they will unknowingly follow the forum. This is a relatively minor harm. However, if combined with some form of deception to trick users into entering sensitive information on the page, it can even lead to financial loss.
X-FRAME-OPTIONS
is currently the most reliable method.
X-FRAME-OPTIONS
is an HTTP
header proposed by Microsoft specifically used to defend against ClickJacking attacks using iframe
nesting.
When it comes to inducing users to click and enter a website, utilizing CSS hijacking can be a good approach. Whether it's a forum or an email, there is usually a rich text editor. If the website does not pay attention to this type of attack and handle it properly, it can be easily exploited.
By inserting a link into the rich text, it should normally be <a href="xxx"></a>
. However, if we apply a style to it or wrap it with a font style, setting the style to display: block; z-index: 100000; position: fixed; top: 0; left: 0; width: 1000000px; height: 100000px;
, which means making the link a block-level element that covers the entire screen, then regardless of where the user clicks on the page, they will be redirected to the specified page. This hijacks the traffic to your page. If the user does not notice the change in the URL, phishing can also be carried out on the redirected page. To mitigate this type of attack, CSS isolation methods such as CSS modules, shadow DOM, and namespaces are commonly used.