如何防止客户端控制台在Firebase Web应用程序中被黑客攻击? [英] How do you prevent client side console hacks on firebase web apps?

查看:118
本文介绍了如何防止客户端控制台在Firebase Web应用程序中被黑客攻击?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我发现有了这么多的客户端逻辑,恶意用户可以通过在任何浏览器中使用控制台来欺骗,重写或游戏firebase应用程序。

例如,

,我可以输入$(。flag)。click()和三个笔画标记每一个帖子在我的应用程序不存在



我写的任何防御性逻辑任何人都可以使用它。



你如何处理这个问题?是否有解决方法?

解决方案

实际上,Firebase与其他服务器进程在安全性方面没有区别。任何人都可以在任何站点上打开JavaScript控制台(或者编写自己的HTML页面,或者从命令行运行curl)来尝试操纵数据。

直截了当,但令人惊讶的是强大的安全规则。将这些与身份验证模式耦合起来,您可以用最小的麻烦来限制对传入数据的访问和验证。

  {
rules:{
// widgetName必须是字符串
widgetName:{.validate:newData.isString()},

//用户帐户只能被认证客户端
users读取:{
$ user_id:{$ b $.read:$ user_id === auth.id




code $ pre

It dawned on me that with so much client side logic, malicious users can spoof, override or game firebase apps by using the console in any browser.

For instance, I can enter $(".flag").click() and with three strokes flag every post out of existence on my app.

Any defensive logic I write will all be available to anyone who wants to crack it.

How have you dealt with this? Is there a work around?

解决方案

In reality, Firebase is no different than any other server process with regards to security. Anybody can open the JavaScript console on any site (or write their own HTML page, or run curl from the command line) to try to manipulate data.

Firebase moderates clients using straightforward but surprisingly powerful security rules. Couple those with an authentication schema, and you can restrict access to, and validate any incoming data with minimal fuss.

{
   "rules": {
       // widgetName must be a string
       "widgetName: { ".validate": "newData.isString()" },

       // user accounts can only be read by the authenticated client
       "users": {
           "$user_id": {
               ".read": "$user_id === auth.id"
           }
       }
   }
}

这篇关于如何防止客户端控制台在Firebase Web应用程序中被黑客攻击?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆