Skip to content

Commit

Permalink
Merge pull request nodejscn#677 from jinbel/patch-1
Browse files Browse the repository at this point in the history
Update buffer_from_buffer_alloc_and_buffer_allocunsafe.md
  • Loading branch information
nodejh authored Sep 4, 2019
2 parents e6ae561 + 0b61b12 commit 4cd989b
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions buffer/buffer_from_buffer_alloc_and_buffer_allocunsafe.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
由于 `new Buffer()` 的行为因第一个参数的类型而异,因此当未执行参数验证或 `Buffer` 初始化时,可能会无意中将安全性和可靠性问题引入应用程序。

例如,如果攻击者可以使应用程序接收到数字(实际期望的是字符串),则应用程序可能调用 `new Buffer(100)` 而不是 `new Buffer("100")`,它将分配一个 100 个字节的 buffer 而不是分配一个内容为 `“100”` 3 个字节的 buffer。
这通常可以使用 JSON API 调用
由于 JSON 区分数字和字符串类型,因此它允许在天真的应用程序可能期望始终接收字符串的情况下注入数字
使用 JSON API 调用时,是非常有可能发生这种情况的
由于 JSON 区分数字和字符串类型,因此它允许在简单的应用程序可能期望始终接收字符串的情况下注入数字
Node.js 8.0.0 之前,100 个字节的 buffer 可能包含任意预先存在的内存数据,因此可能会用于向远程攻击者暴露内存中的机密。
Node.js 8.0.0 开始,由于数据会用零填充,因此不会发生内存暴露。
但是,其他攻击仍然存在,例如导致服务器分配非常大的 buffer,导致性能下降或内存耗尽崩溃。
Expand Down

0 comments on commit 4cd989b

Please sign in to comment.