- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我按照 MDN 在 Writing a WebSocket server 上提供的指南进行操作。 , 该指南非常简单易懂...
但是,在遵循本教程后,我遇到了发送来自客户端的 WebSocket 消息的框架:
0 1 2 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-------+-+-------------+-------------------------------+
|F|R|R|R| opcode|M| Payload len | Extended payload length |
|I|S|S|S| (4) |A| (7) | (16/64) |
|N|V|V|V| |S| | (if payload len==126/127) |
| |1|2|3| |K| | |
+-+-+-+-+-------+-+-------------+ - - - - - - - - - - - - - - - +
| Extended payload length continued, if payload len == 127 |
+ - - - - - - - - - - - - - - - +-------------------------------+
| |Masking-key, if MASK set to 1 |
+-------------------------------+-------------------------------+
| Masking-key (continued) | Payload Data |
+-------------------------------- - - - - - - - - - - - - - - - +
: Payload Data continued ... :
+ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +
| Payload Data continued ... |
+---------------------------------------------------------------+
在制作了一些函数来正确地取消屏蔽客户端发送的数据和帧之后,这让我想知道为什么数据甚至一开始就被屏蔽了。我的意思是,您不必屏蔽从服务器发送的数据...
如果有人出于不良原因获取数据,则取消屏蔽可能相对容易,因为屏蔽 key 包含在整个消息中。或者即使他们没有 key ,帧中的掩码 key 也只有 2 个字节长。由于 key 非常非常小,因此有人可以轻松地揭开数据的面纱。
我想知道为什么要屏蔽数据的另一个原因是,您可以通过在 TLS/SSL 和 HTTPS 上使用 WSS(WebSockets Secure)来更好地保护您的 WebSocket 数据。
我是否错过了为什么 WebSocket 被屏蔽的重点?似乎它只是增加了毫无意义的努力来揭露客户端发送的数据,而它并没有增加任何安全性。
最佳答案
实际上是权威的 RFC,RFC 6455 The WebSocket Protocol ,有解释。我在这里引用它:
10.3. Attacks On Infrastructure (Masking)
In addition to endpoints being the target of attacks via WebSockets,
other parts of web infrastructure, such as proxies, may be the
subject of an attack.
As this protocol was being developed, an experiment was conducted to
demonstrate a class of attacks on proxies that led to the poisoning
of caching proxies deployed in the wild [TALKING]. The general form
of the attack was to establish a connection to a server under the
"attacker's" control, perform an UPGRADE on the HTTP connection
similar to what the WebSocket Protocol does to establish a
connection, and subsequently send data over that UPGRADEd connection
that looked like a GET request for a specific known resource (which
in an attack would likely be something like a widely deployed script
for tracking hits or a resource on an ad-serving network). The
remote server would respond with something that looked like a
response to the fake GET request, and this response would be cached
by a nonzero percentage of deployed intermediaries, thus poisoning
the cache. The net effect of this attack would be that if a user
could be convinced to visit a website the attacker controlled, the
attacker could potentially poison the cache for that user and other
users behind the same cache and run malicious script on other
origins, compromising the web security model.
To avoid such attacks on deployed intermediaries, it is not
sufficient to prefix application-supplied data with framing that is
not compliant with HTTP, as it is not possible to exhaustively
discover and test that each nonconformant intermediary does not skip
such non-HTTP framing and act incorrectly on the frame payload.
Thus, the defense adopted is to mask all data from the client to the
server, so that the remote script (attacker) does not have control
over how the data being sent appears on the wire and thus cannot
construct a message that could be misinterpreted by an intermediary
as an HTTP request.
Clients MUST choose a new masking key for each frame, using an
algorithm that cannot be predicted by end applications that provide
data. For example, each masking could be drawn from a
cryptographically strong random number generator. If the same key is
used or a decipherable pattern exists for how the next key is chosen,
the attacker can send a message that, when masked, could appear to be
an HTTP request (by taking the message the attacker wishes to see on
the wire and masking it with the next masking key to be used, the
masking key will effectively unmask the data when the client applies
it).
It is also necessary that once the transmission of a frame from a
client has begun, the payload (application-supplied data) of that
frame must not be capable of being modified by the application.
Otherwise, an attacker could send a long frame where the initial data
was a known value (such as all zeros), compute the masking key being
used upon receipt of the first part of the data, and then modify the
data that is yet to be sent in the frame to appear as an HTTP request
when masked. (This is essentially the same problem described in the
previous paragraph with using a known or predictable masking key.)
If additional data is to be sent or data to be sent is somehow
changed, that new or changed data must be sent in a new frame and
thus with a new masking key. In short, once transmission of a frame
begins, the contents must not be modifiable by the remote script
(application).
The threat model being protected against is one in which the client
sends data that appears to be an HTTP request. As such, the channel
that needs to be masked is the data from the client to the server.
The data from the server to the client can be made to look like a
response, but to accomplish this request, the client must also be
able to forge a request. As such, it was not deemed necessary to
mask data in both directions (the data from the server to the client
is not masked).
Despite the protection provided by masking, non-compliant HTTP
proxies will still be vulnerable to poisoning attacks of this type by
clients and servers that do not apply masking.
关于security - 为什么 WebSockets 被屏蔽了?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33250207/
我需要创建一个 View (作为其他 View 的 mask ) 。圆圈是透明的,外部区域是半透明的。我可以使用 canvas.clipRegion(..) 来实现它,但是 http://develo
踏入爬虫的迷宫 多年以来,我一直是一个对编程充满了好奇心的人。探索着代码的世界,便如同探险家踏入密林深处,寻找未知的宝藏。最近,我将目光聚焦在了爬虫技术上,特别是百度搜索屏蔽问题上。 百度搜索的诱惑
我想将“www.adomain.com”重定向到“www.adomain.com/cms”。 cms 部分应该被屏蔽。 我无法让它安静地工作。因此“cms”始终是网址的一部分。 我尝试了这个解决方案:
我一直在我的 View Controller 中使用以下代码: UIView *view = [[CustomView alloc] init]; UIView *mask = [[CustomMas
如果是网页内容里面的alert,我们可以等网页加载完毕,也就是在webViewDidFinishLoad中执行下面的js代码,就可以屏蔽alert了
我正在使用 PyQt4 QLineEdit小部件接受密码。有一个setMasking属性,但不遵循如何设置屏蔽字符。 最佳答案 editor = QLineEdit() editor.setEchoM
我有一个包含员工信息的 Pandas 数据框,如下所示: df=pd.DataFrame({ 'Id':[1,2,3,4], 'Name':['Joe','Henry','Sam','
我正在为 iPhone 创建一个自定义开/关切换开关(类似于标准开关),并且我正在设置 slider 的蒙版,但调用 [[myView [layer] setMask:maskLayer] 设置
我如何能够在 Objective C 中屏蔽 nsimageview?例如,有一个带圆角的 nsimageview。 最佳答案 你不知道。如果你想以 NSImageView 不支持的方式绘制图像,则需
我正在开发一个可以更改边框或矩形 UIImage 的应用程序。边框会有所不同,但看起来 UIImage 是用剪刀剪掉的,或者有什么影响。 做到这一点的最佳方法是什么? 我的第一个想法是准备一堆具有我正
我需要屏蔽数据,就像在 Azure Pipelines 中一样,但位于 Azure 存储库文件内。有没有一种方法可以设置与脚本分开存储的变量,例如在 Azure 管道中: variable = $(S
我没有找到解决问题的简单方法。我想使用 TextInputDialog,您必须在其中键入用户密码,以重置数据库中的所有数据。 TextInputDialog 的问题是它没有屏蔽文本,我不知道有什么选择
我正在寻找一种自行开发的方法来扰乱生产数据以用于开发和测试。我已经构建了几个脚本来生成随机社会安全号码、轮类出生日期、打乱电子邮件等。但我在尝试打乱客户姓名时遇到了困难。我想保留真实姓名,这样我们仍然
我正在尝试使用过滤器来屏蔽 SSN 的前 5 位数字,它应该看起来像这样 XXX-XX-1234 到目前为止我想出了什么: // {{SocialSecurityNumber | ssn}} angu
我没有找到解决问题的简单方法。我想使用 TextInputDialog,您必须在其中键入用户密码,以重置数据库中的所有数据。 TextInputDialog 的问题是它没有屏蔽文本,我不知道有什么选择
我想屏蔽一个 Fortran 数组。这是我目前正在做的方式...... where (my_array <=15.0) mask_array = 1 elsewhere mask_ar
当用户在用户界面上输入时,我需要屏蔽数字,用户应该看到一个屏蔽的数字,但在 Java 代码上,我应该得到整个数字,包括屏蔽的字符用户应该看到什么 4545********9632但在 Java 代码(
我正在使用 javafx 文本字段。我需要输入数字以及应符合格式 ###.###.###.### 的小数其中小数点根本不可编辑,数字可以是任何数字;不允许其他输入。并非所有数字占位符都需要填写,例如它
我必须交付一个小型 C++ 软件。我想用一些实现(我使用了表达式模板)来掩盖头文件,以使最终用户难以辨认,因此他们无法修改它们。我无法将代码包含在静态或动态库中。有什么方法可以屏蔽头文件的内容吗? 谢
我正在开发一个与 gestureRecognizer 配合使用的应用程序。 使用手势可以选择 UIImage(例如 rectangle.png),并且可以使用 UIPopoverView 通过为所选图
我是一名优秀的程序员,十分优秀!