Day 8:Stored XSS into anchor href attribute with double quotes HTML-encoded : Zero to Hero Series…
文章介绍了一个存储型XSS漏洞实验,通过在评论中注入JavaScript代码(如alert(1)),当用户点击评论中的链接时触发弹窗,成功利用了应用程序对用户输入的处理不当。 2025-7-1 10:27:52 Author: infosecwriteups.com(查看原文) 阅读量:9 收藏

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 24 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:

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 stored cross-site scripting vulnerability in the comment functionality. To solve this lab, submit a comment that calls the alert function when the comment author name is clicked.

This is what the lab looks like, and we can see that there are no input fields here. However, we have an option to view the post.

We have an input field to leave a comment. Let’s fill it out with normal details and observe how it responds.

Comments have been submitted

The comment has been posted, and we can see a hyperlink in it. Let’s click on ‘RayofHope’ and see where it redirects.

It redirected to nobody.com. Let’s look at the code to analyze why this happened.

The application is automatically wrapping the username or comment ("RayofHope") in an <a> tag, and assigning it a default href of https://nobody.com, likely as a placeholder or default profile link for anonymous users or non-registered commenters.

Let’s try injecting javascript:alert(1)

The script has been submitted and the lab is now solved. Let’s go back to the blog to check if any popup appears.

As expected, clicking on the comment successfully triggered the XSS payload, resulting in a pop-up. Let’s now analyze the code to understand why it was executed.

In this case, the href attribute of the anchor tag is set to a javascript: URI scheme. When the user clicks on the link labeled 'ray', the browser interprets and executes the embedded JavaScript (alert(1)), confirming an XSS vulnerability.


文章来源: https://infosecwriteups.com/day-8-stored-xss-into-anchor-href-attribute-with-double-quotes-html-encoded-zero-to-hero-series-f4bcab7d9b8f?source=rss----7b722bfd1b8d---4
如有侵权请联系:admin#unsafe.sh