UI Attacks
UI attacks exploit user trust and perception:
Unintended actions: Users click what they think is safe but isn't
Authorization bypass: Authentic user actions perform attacker's request
Credential theft: Users enter credentials for fake forms
Session hijacking: Steal authentication tokens
Settings modification: Change user preferences, disable security
Fund transfers: Trick users into authorizing transfers
Account deletion: Trick users into deleting their accounts
UI attacks are hard to detect because the user intentionally performs the action.
Real-World Attack Scenarios
Scenario 1: Clickjacking - Invisible Frame
Attacker embeds target website in invisible iframe and overlays with fake interface:
<!-- Attacker's page -->
<html>
<head>
<style>
#target-frame {
position: absolute;
width: 400px;
height: 300px;
top: 10px;
left: 10px;
opacity: 0.00001; <!-- INVISIBLE -->
z-index: 9999;
}
.decoy-button {
position: absolute;
top: 150px;
left: 150px;
width: 100px;
height: 30px;
background: red;
cursor: pointer;
z-index: 1000;
}
</style>
</head>
<body>
<h1>Click to win free prize!</h1>
<button class="decoy-button">CLICK HERE!</button>
<!-- Invisible frame to target site -->
<iframe id="target-frame"
src="https://bank.com/transfer?account=attacker&amount=1000">
</iframe>
</body>
</html>How it works:
User visits attacker's page
Sees "Click to win free prize!" button
Clicks the button
Actually clicks the invisible button on the embedded frame
Bank's "Transfer" button gets clicked
$1000 transferred to attacker
The attack:
User thinks they're claiming a prize. Actually they:
Authorize a bank transfer
Delete their account
Change their email
Enable attacker's two-factor authentication
Any action that requires a click
Result:
User performs attacker's intended action
Completely authenticated (it's the user's click)
No server-side detection
No login required
Finding it: Check if page can be framed. Try embedding in iframe. Look for X-Frame-Options header.
Scenario 2: Button Overlay - Precise Clickjacking
Attacker precisely overlays fake button on real button:
The attack:
Page shows "Click here for free WiFi!" button
User clicks the (fake) button
Actually clicks invisible overlay
User's account deleted
Attacker gains access (password already reset)
Result:
Account takeover
Deletion of user data
Any action performable
Finding it: Look for invisible elements. Use browser DevTools to inspect z-index. Try clicking UI elements and checking for unexpected actions.
Scenario 3: Cursorjacking - Fake Cursor
Attacker hides real cursor and displays fake cursor offset from actual position:
The attack:
User sees fake cursor displaced from real cursor
User clicks where fake cursor points
Actually clicks where real cursor is (50 pixels away)
Clicks invisible button
Unexpected action performed
Result:
Actions performed at different location than displayed
Unintended clicks on hidden elements
Scenario 4: window.opener Trust Issue
Parent window opens child window, trusts connection back:
The vulnerability:
When a child window is opened via window.open(), it has access to window.opener, allowing it to:
Navigate parent to attacker's page
Read parent's data
Call parent's functions
Perform XSS on parent
The attack:
Attacker opens legitimate website in new window:
window.open('https://bank.com')Bank loads in child window
Attacker malicious code in child window executes
Uses
window.openerto access parentRedirects parent to phishing site
Steals parent window's data
Result:
Parent window hijacked
Data theft from parent
Phishing redirect
XSS on parent page
Finding it: Check for window.opener usage. Test if child windows can redirect parent. Verify rel="noopener" attribute.
Scenario 5: Drag & Drop XSS
Attacker tricks user into dragging content that executes JavaScript:
The attack:
User drags element from attacker's page
Drops it in their email/document
JavaScript embedded in drag data executes
Compromise of email or document
Result:
XSS in email clients
Malware distribution
Account compromise
How to Identify UI Attacks During Testing
1. Test clickjacking
Check if page can be embedded in iframe:
If it loads, clickjacking possible. Check for X-Frame-Options header.
2. Test cursor manipulation
Look for:
Hidden cursor (
cursor: none)Fake cursor elements
Position manipulation
3. Test window.opener
Open target in new window and test:
4. Check headers
Look for security headers:
X-Frame-OptionsContent-Security-PolicyX-Content-Type-Options
5. Test overlay detection
Place invisible elements and verify they're not clickable.
6. Test drag & drop
Drag elements and monitor what data is transferred.
Mitigation Strategies
Prevent clickjacking with X-Frame-Options
Or:
Or in CSP:
Use rel="noopener noreferrer"
For all links that open new windows:
Prevents window.opener access.
Implement user interaction confirmation
For sensitive actions:
Detect framing
Disable drag and drop of sensitive data
CSP to prevent data exfiltration
Verify user intent
For critical actions (delete, transfer):
Require additional confirmation
Use CAPTCHA
Verify email address
Require SMS code
Last updated