MongoDB RegEx在聚合器安全方面的注意事项

我正在使用聚合方法来收集来自不同集合的数据。正则表达式用于实现对用户的搜索。 MongoDB文本搜索对我来说不是一个选择,因为它将需要创建索引,这会占用大量内存。查询如下:

Users.aggregate([
{
  $match: {
    $or: [
        {email: new RegExp(searchTerm,'ig')},{'userLocation.country': new RegExp(searchTerm,'ig')}
    ]
  }
},{
  $lookup: {
    from: 'orders',localField: 'id',foreignField: 'userid',as: 'orders'
  }
}
])

searchTerm是保存用户输入的变量。我添加了maxTimeMS来防止正则表达式DDOS攻击。可以利用什么可能的方式?

zqp19880915 回答:MongoDB RegEx在聚合器安全方面的注意事项

暂时没有好的解决方案,如果你有好的解决方案,请发邮件至:iooj@foxmail.com
本文链接:https://www.f2er.com/2999655.html

大家都在问