Day 6:DOM XSS in jQuery selector sink using a hashchange event : Zero to Hero Series — Portswigger
文章介绍了一个基于DOM的XSS漏洞实验室,利用jQuery的`$()`函数和`location.hash`属性触发漏洞。攻击者通过构造payload,在受害者浏览器中调用`print()`函数。 2025-7-2 06:38:34 Author: infosecwriteups.com(查看原文) 阅读量:29 收藏

RayofHope

Hi, my fellow hackers. This is Rayofhope. I have over 5 years of experience and am currently working as a consultant with a Big 4 firm.

It’s Day 22 of posting all the PortSwigger labs, not just the solutions. I’ll break down why we take each step, because once the ‘why’ is clear, the ‘how’ becomes easy.

Let’s Start:

Before you go for this blog, make sure to read the Previous one
https://arayofhope7.medium.com/day-5-dom-xss-in-jquery-anchor-href-attribute-sink-using-location-search-afc598397e24

Video Walkthrough — You can watch the video or read the blog, totally up to you. But if you ask me, start with the video, then read the blog to connect all the dots.

LAB: This lab contains a DOM-based cross-site scripting vulnerability on the home page. It uses jQuery’s $() selector function to auto-scroll to a given post, whose title is passed via the location.hash property.

To solve the lab, deliver an exploit to the victim that calls the print() function in their browser.

This is what the lab looks like.

A hash is the part of the URL that comes after the # symbol.

This confirms that the application is vulnerable to DOM-based XSS due to the unsanitized use of window.location.hash in a hashchange event listener.

We can see that there is an exploit server available. Let’s deliver the payload through it.

In here, the iframe's src attribute points to the vulnerable page with an empty hash value. When the iframe is loaded, an XSS payload is appended to the hash, causing the hashchange event to fire.


文章来源: https://infosecwriteups.com/day-6-dom-xss-in-jquery-selector-sink-using-a-hashchange-event-zero-to-hero-series-portswigger-f80367168d95?source=rss----7b722bfd1b8d---4
如有侵权请联系:admin#unsafe.sh