Overview
Cross-Frame Scripting (XFS), also known as Clickjacking, is an attack that combines malicious JavaScript with an iframe that loads a legitimate page in an effort to steal data from an unsuspecting user. This attack is usually only successful when combined with social engineering.How the Attack Works
An attacker convinces a user to navigate to a web page the attacker controls. The attacker’s page then loads malicious JavaScript and an HTML iframe pointing to a legitimate site. Once the user enters credentials into the legitimate site within the iframe, the malicious JavaScript steals the keystrokes.Basic Attack Example
Here’s a simple demonstration of how easy it is to spoof a website using an iframe:Penetration Testing
Test Embedding
If the page loads successfully in the iframe, the vulnerability can likely be exploited.
Sophisticated Attack Variations
Advanced Techniques
Advanced Techniques
Threat actors can enhance this attack by:
- Proxy-Based Attacks: Serve both sites through a proxy to circumvent any CORS Content Security Policy (CSP)
- Back-to-Base Scripts: Intercept and transmit input data (username, password, credit card, etc.) without the user knowing
- Real-Time Interaction: Have a threat actor listening for inputs and interacting/handling the victim, which is how 2FA is often bypassed
Countermeasures
Technical Protections
Defense Strategy
- End User Education: Train users to recognize phishing attempts and suspicious URLs
- Server Monitoring: Monitor server logs for unusually repetitive GET calls
- Content Security Policy: Implement a CSP that blocks
<iframe>loading withframe-ancestors 'none' - X-Frame-Options Header: Set to
DENYorSAMEORIGINto prevent embedding
Related Vulnerabilities
- Content Security Policy (CSP) bypass
- Cross-Site Request Forgery (CSRF)
- Two-Factor Authentication (2FA) bypass
- Social engineering attacks
