Ajax XML 存在 XSS 验证问题

发布于 2024-08-18 09:30:56 字数 262 浏览 2 评论 0原文

在 Web 应用程序中使用 Ajax 时,我们使用 XML 在服务器和客户端之间传输数据。然而 XSS 验证出现了, 所以问题是, 1. 这样传递XML是否正确? 2. 如果关闭 XSS 验证,我们是否会面临安全问题? 3. 通过 header (content-type = application/xml) 传递 Ajax 请求可以解决这个问题吗?

JSON 也是传输数据的好方法,但它是调用 XSS 的方法。 那么什么是正确的和不正确的呢?建议一些好的做法。 请提供您的意见。 谢谢,

While using Ajax in web applications we use XML to transfer the data between server and client. However XSS validation comes into picture,
So questions are,
1. Is passing XML like this is correct?
2. Are we exposed to security issues if we turn off XSS validation?
3. Can passing Ajax request with header (content-type = application/xml) solve this problem ?

JSON is also good approach to transfer the data but that to invoke XSS.
So what is correct and incorrect? Suggest some good practices.
Please provide your input for the same.
Thanks,

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

纵情客 2024-08-25 09:30:56

我更喜欢使用 JSON 来实现此目的;比 XML 轻量得多,并且由于它是一个 javascript 对象,因此使用事件处理程序中返回的数据变得很简单。请注意不要对 JSON 对象进行 eval(),因为这会危及安全性 - 请参阅 JavaScript 的时间eval() 不是邪恶的吗?

至于 XSS 保护,它的存在是有充分理由的。我从您的帖子中得知,客户端代码托管在与数据源不同的域上?只有在这种情况下,XSS 保护才会生效。您可能想研究一下针对此场景开发的 JSONp,尽管它也有自己的一组安全问题: http://en.wikipedia.org/wiki/JSON#JSONP

希望这有帮助,

JS

I prefer using JSON for this; much more lightweight than XML, and since it is a javascript object it becomes trivial to make use of the data returned in your event handler. Just be careful not to eval() your JSON object as this compromises security - see When is JavaScript's eval() not evil?

As for the XSS protection, it is there for good reason. I take it from your post that the client code is hosted on a different domain to the datasource? XSS protection only comes into effect if that is the case. You might want to look into JSONp which has been developed for this scenario, though it too carries it's own set of security concerns: http://en.wikipedia.org/wiki/JSON#JSONP

Hope this helps,

JS

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文