这被认为是 DOM-XSS 或 self-XSS 或两者兼而有之?

Is this considered DOM-XSS or self-XSS or both?

场景:

网页显示使用这些 javascript 行的错误登录页面

<script>
    let queryParams = new URLSearchParams(window.location.search);
    document.getElementById("message").innerText = queryParams.get("message");
    let link = document.getElementById("link");
    link.innerText = queryParams.get("linkText");
    link.href = queryParams.get("linkUrl");
</script>

最后 javascript 行允许我将 javascript 隐藏在网页中的 link 内,制作如下所示的 url。

https://vulnerablewebsite.com/folder/custom.html?message=not+correct?&linkUrl=javascript:alert(1)&linkText=click+here+to+shine

1) 用户点击这个link

的缩略版

2) 用户点击"click here to shine"

3) 警报打开

这篇关于 portswigger 的文章启发了我 https://portswigger.net/web-security/cross-site-scripting/dom-based
特别是这个例子

If a JavaScript library such as jQuery is being used, look out for sinks that can alter DOM elements on the page. For instance, the attr() function in jQuery can change attributes on DOM elements. If data is read from a user-controlled source like the URL and then passed to the attr() function, then it may be possible to manipulate the value sent to cause XSS. For example, here we have some JavaScript that changes an anchor element's href attribute using data from the URL:

$(function(){ $('#backLink').attr("href",(new URLSearchParams(window.location.search)).get('returnUrl')); });

You can exploit this by modifying the URL so that the location.search source contains a malicious JavaScript URL. After the page's JavaScript applies this malicious URL to the back link's href, clicking on the back link will execute it:

?returnUrl=javascript:alert(document.domain)

问题: 对我来说,它们看起来是同一种攻击,但有人告诉我这是一个自我 XSS。无论如何,我读到 self-XSS 希望用户在他的控制台中自行粘贴 javascript 代码。所以我很困惑,我想知道它是哪种类型。另外,是否可以认为是 medium/high 严重程度的漏洞?

命名并不重要,但是

  • 这绝对是一个漏洞,根据CVSSv3它可能是一个媒介,但是你可以针对这个具体情况自己计算。

  • 这不是 self xss,你自己通过 link 展示了一种方法,如果攻击者将其发送给受害者会使页面易受攻击。

  • 肯定是 dom xss,因为它完全在 javascript 中,不需要服务器往返。