简体   繁体   English

这是什么类型的 XSS 以及如何防止它

[英]What type XSS this is and how to prevent it

Here is the code of example.com that I saved to my computer desktop as index.html:这是我作为 index.html 保存到计算机桌面的 example.com 的代码:

<channel> <title>Comments on: Voor uw organisatie</title> <atom:link href="https://example.com/feed/" rel="self" type="application/rss+xml" /> <link>https://example.com</link> <description>PIM: Wie weet wat van mij?</description> <lastBuildDate>Mon, 17 Sep 2018 13:22:52 +0000</lastBuildDate> <sy:updatePeriod>hourly</sy:updatePeriod> <sy:updateFrequency>1</sy:updateFrequency> <generator>https://wordpress.org/?v=4.9.3</generator> </channel> 

I opened that file in a text editor and changed我在文本编辑器中打开该文件并更改

<generator>https://wordpress.org/?v=4.9.3</generator> 

to

<generator>"><img src="x" onerror="alert(document.cookie)"></generator> 

When I opened the modified HTML file in Firefox I get an alert box with cookies.当我在 Firefox 中打开修改后的 HTML 文件时,我收到一个带有 cookie 的警告框。 I know it is XSS, because I am getting that XSS alert in my browser.我知道这是 XSS,因为我在浏览器中收到了 XSS 警报。

My question is why is this happening?我的问题是为什么会发生这种情况? Cause I didn't injected this code in a parameter.因为我没有在参数中注入这段代码。 So how can developer fix this or sanitize this code?那么开发人员如何解决这个问题或清理这段代码呢?

Is there any impact of this?这有什么影响吗?

Given a website run by Alice and visited by Bob, an XSS attack would occur when Mallory (an attacker) caused JavaScript to run in Alice's browser on Bob's website.给定一个由 Alice 运行并由 Bob 访问的网站,当 Mallory(攻击者)使 JavaScript 在 Bob 的网站上的 Alice 浏览器中运行时,就会发生 XSS 攻击。

Alice editing an HTML document on her computer (even one copied from another website) so it runs JavaScript, and then loading that HTML document in her browser is not performing an XSS attack. Alice 在她的计算机上编辑 HTML 文档(甚至是从另一个网站复制的),使其运行 JavaScript,然后在她的浏览器中加载该 HTML 文档不会执行 XSS 攻击。 She is just running JavaScript on a system she has complete control over.她只是在她完全控制的系统上运行 JavaScript。

This isn't XSS, this is broken HTML.这不是 XSS,这是损坏的 HTML。 The alert is a false positive.警报是误报。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM