WebSocket 和 Origin header 字段

WebSocket and the Origin header field

以下引用自 RFC6455 - WebSocket 协议。

Servers that are not intended to process input from any web page but only for certain sites SHOULD verify the |Origin| field is an origin they expect. If the origin indicated is unacceptable to the server, then it SHOULD respond to the WebSocket handshake with a reply containing HTTP 403 Forbidden status code.

The |Origin| header field protects from the attack cases when the untrusted party is typically the author of a JavaScript application that is executing in the context of the trusted client. The client itself can contact the server and, via the mechanism of the |Origin| header field, determine whether to extend those communication privileges to the JavaScript application. The intent is not to prevent non-browsers from establishing connections but rather to ensure that trusted browsers under the control of potentially malicious JavaScript cannot fake a WebSocket handshake.

我只是不能确定第 2 段的意思,尤其是 斜体 部分。谁能解释一下?或者也许是一个例子。

目前我的理解是这样的:

你的理解似乎是正确的,但是..

我会重新措辞 - 你可以肯定,javascript 客户端将发送正确的来源 header。你不知道其他客户端会发送什么(以及值是否正确)。

这应该可以防止其他页面连接到 "your" 网络套接字端点(这很重要,想象一下在 jsfiddle 或某些经常访问的页面上的某处注入 javascript),但是如果您需要确保没有其他客户端能够连接到它,您需要引入一些其他安全措施。

我认为这只是为了防止基于浏览器的 "data stealing" 或 "DDoSing",没有别的意思;你仍然可以通过使用其他客户端来做到这一点。