Javascript 劫持,我什么时候应该担心,应该担心到什么程度?

发布于 2024-11-25 08:26:22 字数 659 浏览 0 评论 0原文

好的,所以我正在开发一个已经开始更加ajaxified 的网络应用程序。然后我读了一篇关于 javascript 劫持的博客,我有点困惑什么时候它实际上是一个问题。我需要一些澄清

问题 1: 这是问题/漏洞吗?

如果我的网站使用具有敏感信息的“GET”请求返回 json 数据 那么该信息可能会落入坏人之手。

我使用 ASP.NET MVC,返回 JSON 的方法要求您显式允许 json get 请求。我猜想他们是想保护外行免受这个安全漏洞的影响。

问题 2: 劫持是否是通过嗅探/读取通过互联网发送的响应而发生的? SSL 可以缓解这种攻击吗?

问题 3: 这让我向自己问了这个问题。如果我将页面状态存储在页面的本地 javascript 对象中,有人可以劫持该数据(登录用户除外)吗?

问题 4: 我可以仅通过“POST”请求返回 JSON 来安全地缓解此漏洞吗?

Ok, so I'm developing a web app that has begun to be more ajaxified. I then read a blog that talked about javascript hijacking, and I'm a little confused about when it's actually a problem. I want some clarification

Question 1:
Is this the problem/vulnerability?

If my site returns json data with a 'GET' request that has sensitive
information then that information can get into the wrong hands.

I use ASP.NET MVC and the method that returns JSON requires you to explicitly allow json get requests. I'm guessing that they are trying to save the uninitiated from this security vulnerability.

Question 2:
Does the hijacking occur by sniffing/reading the response as it's being sent through the internet? Does SSL mitigate that attack?

Question 3:
This led me to ask this question to myself. If I'm storing page state in local javascript object(s) of the page, can someone hijack that data(other than the logged in user)?

Question 4:
Can I safely mitigate against THIS vulnerability by only returning JSON with a 'POST' request?

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

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

发布评论

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

评论(3

挖个坑埋了你 2024-12-02 08:26:22

您链接到的帖子正在谈论 CSRF 和 CSRF 。 XSS(请参阅我对这个问题的评论),因此在这种情况下:

这是问题/漏洞吗(“如果我的网站使用包含敏感信息的‘GET’请求返回 json 数据,那么该信息可能会落入坏人之手。”)?

不。

劫持是否是通过嗅探/读取通过互联网发送的响应来发生的?

不。

如果我将页面状态存储在页面的本地 javascript 对象中,有人可以劫持该数据(登录用户除外)吗?

这取决于。这取决于您是否将数据存储在 cookie 中并且尚未设置正确的域或路径。这取决于客户端浏览器上是否存在允许脚本访问通常受限制的数据的安全漏洞。还有许多其他攻击媒介,并且不断发现新的攻击媒介。简而言之:不要信任浏览器任何机密或安全数据。

我可以仅通过“POST”请求返回 JSON 来安全地缓解漏洞吗?

不(这不是单个漏洞,而是一组漏洞类别)。

The post you linked to is talking about CSRF & XSS (see my comment on the question), so in that context:

Is this the problem/vulnerabiliy ("If my site returns json data with a 'GET' request that has sensitive information then that information can get into the wrong hands.")?

No.

Does the hijacking occur by sniffing/reading the response as it's being sent through the internet?

No.

If I'm storing page state in local javascript object(s) of the page, can someone hijack that data(other than the logged in user)?

It depends. It depends on whether you're storing the data in cookies and haven't set the right domain, or path. It depends on whether there's a security vulnerability on the client browser that would allow a script to gain access to data that typically is restricted. There are numerous other vectors of attack, and new ones are discovered all the time. The long and the short of it is: don't trust the browser with any confidential or secure data.

Can I safely mitigate against THIS vulnerability by only returning JSON with a 'POST' request?

No (it's not a single vulnerability, it's a set of classes of vulnerabilities).

老子叫无熙 2024-12-02 08:26:22

好吧,您可以检查是否有获取,以及获取是否来自正确引用者。

从 POST 获取它并不是真的更安全,因为这很容易模拟。

一般来说,您可以采取很多措施来防止跨站点伪造和操纵。

Well you can check if there was a get and if the get was from a correct referrer.

You are not really much safer getting it from a POST because that is just as easy to simulate.

In general there are a lot of things you can do to prevent cross site forgery and manipulation.

め可乐爱微笑 2024-12-02 08:26:22

实际上的漏洞是能够覆盖Array

如果覆盖本机数组,则可以访问构造为数组的 JSON 数据。

该漏洞已在所有主流浏览器中得到修复。

仅当您的客户端使用不安全的浏览器时,您才应该担心这一点。

示例:

window.Array = function() {
  console.log(arguments);
  // send to secret server
}

...

$.get(url, function(data) { ... });

当构造data时,如果返回的JSON中有任何数组,浏览器将调用window.Array,然后调用该数据数组被发送到秘密服务器。

The actually vulnerability is being able to overwrite Array.

If one overwrites the native Array then one get's access to the JSON data that's constructed as an Array.

This vulnerability has been patched in all major browsers.

You should only worry about this if your clients are using insecure browsers.

Example:

window.Array = function() {
  console.log(arguments);
  // send to secret server
}

...

$.get(url, function(data) { ... });

When the data is constructed if there are any arrays in the returned JSON the browser will call window.Array and then that data in that array gets send to the secret server.

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