Day 6:DOM XSS in jQuery selector sink using a hashchange event : Zero to Hero Series — Portswigger
文章介绍了一个基于DOM的跨站脚本(XSS)漏洞实验室。该漏洞利用jQuery的$()函数和location.hash属性实现自动滚动功能。通过构造特定payload并利用iframe和hashchange事件触发漏洞,最终在受害者浏览器中执行print()函数。 2025-7-2 06:38:34 Author: infosecwriteups.com(查看原文) 阅读量:19 收藏

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--bug_bounty
如有侵权请联系:admin#unsafe.sh