How dangerous is a mongo query which is fed directly from a URL query string?

后端 未结 3 1809
野趣味
野趣味 2020-12-29 07:00

I am playing around with node.js, express, and mongoose.

For the sake of getting something up and running right now I am passing the Express query string object dire

3条回答
  •  庸人自扰
    2020-12-29 07:21

    Operator injection is a serious problem here and I would recommend you at least encode/escape certain characters, more specifically the $ symbol: http://docs.mongodb.org/manual/faq/developers/#dollar-sign-operator-escaping

    If the user is allowed to append a $ symbol to the beginning of strings or elements within your $_GET or $_POST or whatever they will quickly use that to: http://xkcd.com/327/ and you will be a gonner, to say the least.

提交回复
热议问题