While testing a single-page web application, you find that the search parameter is echoed back into the page without output encoding, allowing execution of arbitrary JavaScript. The application stores its JWT access token only in the browser's localStorage, not in cookies. What client-side payload would BEST let you steal the token in one step when a victim follows your poisoned search link?
Because the access token is held in localStorage, any JavaScript that executes in the victim's browser can read it directly with localStorage.getItem(). A short script that reads the value and sends it to an attacker-controlled endpoint completes the theft in a single request. Using the Fetch API in an inline script is reliable and requires no additional user interaction. A payload that targets document.cookie, sessionStorage, or document.referrer would not capture the token because it is not stored in those locations.
Ask Bash
Bash is our AI bot, trained to help you pass your exam. AI Generated Content may display inaccurate information, always double-check anything important.
What is localStorage in web applications?
Open an interactive chat with Bash
How does the Fetch API work in JavaScript?
Open an interactive chat with Bash
What is the difference between localStorage and sessionStorage?
Open an interactive chat with Bash
Certified Ethical Hacker (CEH)
Web Application Hacking
Your Score:
Report Issue
Bash, the Crucial Exams Chat Bot
AI Bot
Loading...
Loading...
Loading...
Pass with Confidence.
IT & Cybersecurity Package
You have hit the limits of our free tier, become a Premium Member today for unlimited access.
Military, Healthcare worker, Gov. employee or Teacher? See if you qualify for a Community Discount.
Monthly
$19.99
$19.99/mo
Billed monthly, Cancel any time.
3 Month Pass
$44.99
$14.99/mo
One time purchase of $44.99, Does not auto-renew.
MOST POPULAR
Annual Pass
$119.99
$9.99/mo
One time purchase of $119.99, Does not auto-renew.
BEST DEAL
Lifetime Pass
$189.99
One time purchase, Good for life.
What You Get
All IT & Cybersecurity Package plans include the following perks and exams .