November 16, 2026
Lab : Stored XSS into HTML context with nothing encoded | PortSwigger Web Security Academy
Stored XSS

By Irfan
2 min read
Lab Name: Stored XSS Category: Cross-Site Scripting (XSS) Difficulty: Apprentice Vulnerability: Stored Cross-Site Scripting (Stored XSS) Tools Used: Burp Suite, Web Browser Primary Technique: Persistent JavaScript Injection Payload Used: Impact: Persistent JavaScript execution in visitors' browsers
Author's Note:
This lab demonstrates a Stored Cross-Site Scripting vulnerability where malicious JavaScript is submitted through an input field and stored by the application. Unlike reflected XSS, the injected payload remains stored on the server and executes whenever a user visits the affected page.
Lab Description
This lab demonstrates a stored cross-site scripting vulnerability in the comment functionality.
To solve the lab, submit a comment that calls the alert function when the blog post is viewed.
What is XSS?
Cross-site scripting is a vulnerability where an attacker manages to run their own JavaScript inside someone else's browser, on a website that the victim trusts. The script runs with the same privileges as the real website, so it can read the page, read cookies (if they are not protected), make requests as the logged-in user, and change what the user sees.
Step-by-Step Walkthrough
Step 1 — Launch the lab
Log in to the Web Security Academy, open the lab page and click "Access the lab".
Step 2 — Find the input that gets stored
I clicked "View post" on any blog post and scrolled down. At the bottom there is a comment form with four fields:
Payload
<script>alert(1)</script><script>alert(1)</script><: Starts an HTML tag. script: Defines a JavaScript block in HTML. : Closes the opening script tag. alert: JavaScript function that displays a popup message. (1): Passes 1 as the message to display. : Closes the script tag.
Then clicked Post Comment.
The site accepted it and redirected me back to the blog post. Nothing looked broken — the comment area just appeared empty, because a
Step 5 — Trigger the payload
I clicked "Back to blog" and then opened the same blog post again.
An alert box popped up showing 1.
The lab banner turned green: Congratulations, you solved the lab!
Conclusion :
This lab helped me understand the difference between reflected and stored XSS. Stored XSS is particularly dangerous because the injected script can affect multiple users who access the compromised page, without requiring them to interact with the original malicious input.
Thankyouu!