Course contentsShow
← Security
Lesson 646 of 3,05214. Web Security - XSS and Content InjectionFree lesson

Persistent Backdoors via DOM Manipulation

Creating persistent XSS payloads that maintain access across sessions through storage mechanisms.

Persistent Backdoors via DOM Manipulation

What you'll learn: How attackers use stored XSS and DOM manipulation to maintain malicious access across multiple user sessions.

The Core Idea

A persistent backdoor via DOM manipulation combines Stored XSS (where malicious code is saved in a database or storage) with DOM-Based XSS techniques to create a hidden, lasting foothold in a web application. Unlike simple reflected XSS that executes once, these backdoors survive browser refreshes, logouts, and even system reboots—remaining active every time the victim revisits the compromised page.

How It Works

When an attacker successfully injects malicious JavaScript that gets stored (in a comment field, user profile, or any persistent data), they can manipulate the DOM to:

  1. Create hidden elements that execute on page load
  2. Modify existing page elements to trigger malicious actions
  3. Store additional payloads in browser storage (localStorage, sessionStorage) for future execution
  4. Establish communication channels back to the attacker's server

The Analogy

Think of it like hiding a spare key under your doormat—except this "key" is invisible, copies itself, and texts the burglar every time you come home. Even if you change your locks (log out), the key remains waiting for your return.

Why It's Dangerous

Traditional XSS might steal cookies once. A persistent backdoor continuously:

  • Monitors user activity across sessions
  • Harvests credentials from every login attempt
  • Exfiltrates data automatically whenever the page loads
  • Maintains access even after the initial vulnerability is "fixed" (if storage mechanisms weren't cleared)

Key Takeaway: Persistent backdoors via DOM manipulation turn one-time XSS exploits into long-term surveillance tools by leveraging storage mechanisms and DOM persistence, allowing attackers to maintain covert access across multiple user sessions without re-exploiting the vulnerability.