12

列了 MongoDB 的 Golang 使用,注入攻击防范需要注意的点,请大家看看还有其他需要注...

 2 years ago
source link: https://www.v2ex.com/t/816718
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

V2EX  ›  MongoDB

列了 MongoDB 的 Golang 使用,注入攻击防范需要注意的点,请大家看看还有其他需要注意的没?

  vvhhaaattt · 3 小时 14 分钟前 · 171 次点击
  1. 看到相关 php+mongodb 的示例,看漏洞原因,感觉主要 php 动态语言对参数进行解析变为了 php 中的合法复杂类型,后传递给 mongodb 的驱动。这样用户输入可能解析为合法的列表之类的 php 对象,以及未区分 bson 中的 String 跟 JavaScript 类型,从而造成注入。
  2. 我看了下 Golang 的 MongoDB 官方驱动,BSON 对 JavaScript 类型的数据是跟 string 分开进行处理的,对 string 有做转义,而 golang 中输入一般是 string 类型的。

问题: 那在 Golang 使用 MongoDB 过程中,如果 MongoDB 查询不传拼接后的 JavaScript ,只有单纯的 string ,是否可以防止相关注入呢?


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK