Self-XSS and Social Engineering
What You'll Learn
You'll learn how attackers exploit human psychology to trick users into running malicious JavaScript in their own browsers—a technique called Self-XSS.
The Core Idea
Self-XSS isn't a traditional technical vulnerability in a website. Instead, it's a social engineering attack where attackers manipulate victims into manually pasting and executing malicious JavaScript code into their browser's developer console.
Here's how it works:
- An attacker creates a convincing story: "Copy and paste this code to unlock a secret feature!" or "Run this to see who viewed your profile!"
- The victim opens their browser's developer console (F12)
- The victim pastes the malicious JavaScript
- The code executes with the victim's own session credentials and permissions
Why It's Effective
Think of it like handing someone your house keys after they claim to be a "locksmith inspector." The door (browser security) works perfectly—but you're voluntarily giving access.
Attackers often target social media users with promises of:
- "See who viewed your profile"
- "Get free premium features"
- "Change your account theme"
- "Verify you're a real person"
Why Traditional XSS Defenses Don't Apply
Unlike reflected, stored, or DOM-based XSS where the attacker injects code into the application, Self-XSS requires the victim to be the injector. Content Security Policy (CSP) and input sanitization can't prevent code you willingly paste into the console.
Real-World Impact
Self-XSS can steal session tokens, send messages on your behalf, modify account settings, or exfiltrate private data—all because the code runs in your authenticated session.
Key Takeaway: Self-XSS exploits human trust rather than technical flaws; never paste code from untrusted sources into your browser console, regardless of promised benefits.