【问题标题】:Meteor. Prevent multiple inserts from console流星。防止从控制台多次插入
【发布时间】:2023-04-08 22:02:01
【问题描述】:


假设我是个坏人,我看到那个网站使用 Meteor。
我在 js 文件中搜索一个集合描述(让它成为“帖子”),并在控制台中写入

for (var i = 0; i < 10000000000; i++) {
  Posts.insert({title:'foobar'});
}

我们的数据库中充满了垃圾。
如何防止这种情况?我想,这种攻击的注册问题不大。

【问题讨论】:

    标签: javascript meteor spam-prevention


    【解决方案1】:

    使用 allow rules

    首先删除不安全的包:

    meteor remove insecure
    

    然后制定一些规则(例如您必须登录)&在下面的示例中您只能修改自己的文档。

    服务器端代码

    Posts.allow({
      insert: function (userId, doc) {
        // the user must be logged in, and the document must be owned by the user
        return (userId && doc.owner === userId);
      },
      update: function (userId, doc, fields, modifier) {
        // can only change your own documents
        return doc.owner === userId;
      },
      remove: function (userId, doc) {
        // can only remove your own documents
        return doc.owner === userId;
      }
    });
    

    【讨论】:

    • 我建议使用拒绝规则来检查用户的存在,用户与文档所有者的平等,并且作为速率限制措施,以前的文档的创建时间早于例如 30 秒,过去 24 小时内的文档数小于例如 50。
    • 是的,我可能应该添加它,因为速率限制我们必须限制每个连接。我们是否能够从允许回调中访问连接/ID/实例?如果是每个连接?这不是一个更好的主意吗?
    • 实际上最好像你建议的那样检查时间戳。这是如果OP想要这样吗? @user3489952
    • 是的,检查时间戳正是我没有想到的。谢谢大家。并请解释每个连接的速率限制,如果可能的话,请))
    • 连接当前无法允许/拒绝,请关注此线程:groups.google.com/forum/#!topic/meteor-core/LUBfaUtfo7c
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2013-02-23
    • 1970-01-01
    • 1970-01-01
    • 2016-12-31
    • 2010-11-07
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多