简体   繁体   English

Firebase 功能第二代 - 运行时隐私和安全

[英]Firebase functions 2nd generation - runtime privacy and safety

I've just made a migration from 1st gen Firebase functions to 2nd gen.我刚刚从第一代 Firebase 功能迁移到第二代。 In this documentation , there written: GCP does not guarantee the pure safety of the data stored in a form of env variable.在本文档中,写到:GCP 不保证以 env 变量形式存储的数据的纯粹安全性。 The article also recommends use of Secret Manager which is much more expensive than the read op of Firestore.文章还推荐使用Secret Manager ,它比 Firestore 的读取操作要贵得多。 It also means that Google does not guarantee the safety of the env variables in the Firebase functions' runtime.这也意味着谷歌不保证 Firebase 函数运行时环境变量的安全性。 I use Node.js 16 runtime within 2nd gen of Firebase functions.我在 Firebase 函数的第二代中使用 Node.js 16 运行时。

Is 2nd gen Firebase functions' Node.js 16 runtime environment safe enough to use sensitive data within runtime?第二代 Firebase 函数的 Node.js 16 运行时环境是否足够安全,可以在运行时使用敏感数据? I'm planning to read the most sensitive data from Firestore within the 2nd gen Firebase functions' Node.js 16 runtime and use it without logging it in my code.我计划在第二代 Firebase 函数的 Node.js 16 运行时中从 Firestore 读取最敏感的数据,并在不将其记录在我的代码中的情况下使用它。 But, if such secure data like env variables can be logged in some kind of runtimes(which are not specified in the above documentation), it would be frustrating for me to find out and handle such security exceptions.但是,如果像 env 变量这样的安全数据可以记录在某种运行时(上述文档中未指定),那么找出并处理此类安全异常会让我感到沮丧。 So i want to make sure that the data retrieved from Firestore in the 2nd generation Firebase Functions' Node.js 16 runtime is completely safe.所以我想确保从第二代 Firebase Functions 的 Node.js 16 运行时中检索到的数据是完全安全的。 Unfortunately, i couldn't have found any proper documentation specifying such safety guarantee of Node.js 16 runtime.不幸的是,我找不到任何适当的文档来指定 Node.js 16 运行时的这种安全保证。

+as @Doug mentioned in the comment, completely safe is too ambiguous in the context. +正如评论中提到的@Doug, completely safe在上下文中太模棱两可了。 So here's the details for the safety in the question:因此,这是问题中安全性的详细信息:

Environment variables can be used for function configuration, but are not recommended as a way to store secrets such as database credentials or API keys.环境变量可用于 function 配置,但不建议将其用作存储机密信息(例如数据库凭据或 API 密钥)的方式。 These more sensitive values should be stored outside both your source code and outside environment variables.这些更敏感的值应该存储在您的源代码和外部环境变量之外。 Some execution environments or the use of some frameworks can result in the contents of environment variables being sent to logs, and storing sensitive credentials in YAML files, deployment scripts or under source control is not recommended.某些执行环境或使用某些框架会导致环境变量的内容被发送到日志中,并且不建议将敏感凭据存储在 YAML 文件、部署脚本或源代码控制下。 For storing secrets, we recommend that you review the best practices for secret management.对于存储机密,我们建议您查看机密管理的最佳实践。 Note that there is no Cloud Functions-specific integration with Cloud KMS.请注意,Cloud KMS 没有特定于 Cloud Functions 的集成。

Safety in the context is as following: Considering the comments above from the official docs, i want to make sure that my retrieved data from Firestore or elsewhere, string constants in my index.js and runtime environment variables, not to be logged or recorded at all.上下文中的安全性如下:考虑到官方文档的上述评论,我想确保我从 Firestore 或其他地方检索到的数据、我的 index.js 中的字符串常量和运行时环境变量,不会被记录或记录在全部。 Most of all, not to be exposed to client side who triggers the function;.最重要的是,不要暴露给触发 function; 的客户端。

If the runtime is safe and free from any kind of exposure of Firestore data retrieved to client side, necessity of Secret Manager and higher price will just disappear.如果运行时是安全的,并且不会将检索到的 Firestore 数据暴露给客户端,那么 Secret Manager 的必要性和更高的价格就会消失。

Your quote from the documentation is basically saying that env vars lack security because they are freely and easily readable by any code that you deploy along with them, including third party libraries and modules.您从文档中引用的内容基本上是说 env vars 缺乏安全性,因为您与它们一起部署的任何代码(包括第三方库和模块)都可以自由且轻松地读取它们。 For that reason, putting highly "dangerous" values, such as credentials and API keys in env vars leaves them easily exfiltrated (intentionally or unintentionally).因此,在环境变量中放置高度“危险”的值,例如凭据和 API 密钥会使它们很容易被泄露(有意或无意)。 That's the warning here, and nothing more.这就是这里的警告,仅此而已。

On top of that, env vars are sometimes stored in source code, which is often a worse situation.最重要的是,环境变量有时存储在源代码中,这通常是更糟糕的情况。 So you now have two reasons not to use env vars for data that must remain secret.因此,您现在有两个理由不将环境变量用于必须保密的数据。

Secret Manager is the recommended solution because it operations on the principle of least privilege , giving you the ability to determine exactly who or what can see the values, and nothing more. Secret Manager 是推荐的解决方案,因为它以最小权限原则运行,让您能够准确地确定谁或什么可以看到这些值,仅此而已。 This is the best option for security - you should only give access to secrets to those who have it.这是安全性的最佳选择——您应该只向拥有秘密的人提供访问权限。

If you use a database like Firestore to hold your secrets, you are going to have a problem implementing least privilege.如果您使用 Firestore 之类的数据库来保存您的秘密,那么您将在实现最小权限时遇到问题。 This is primarily because anyone who has read access to your project will be able to simply open up the console and start viewing the database right there.这主要是因为任何对您的项目具有读取权限的人都可以简单地打开控制台并开始查看数据库。 You can't control the permissions on those individual documents.您无法控制对这些单个文档的权限。 Firestore wasn't designed for that. Firestore 不是为此而设计的。 Secret Manager was designed precisely for this case. Secret Manager 正是针对这种情况而设计的。

If you are the only person who has access to your project console, then you don't have a problem with security like this (yet).如果您是唯一可以访问您的项目控制台的人,那么您不会遇到这样的安全问题(目前)。 It's entirely up to you if you want to do security in the best possible way, or just get away with an easier solution.如果您想以最好的方式进行安全保护,或者只是使用更简单的解决方案,这完全取决于您。 It's up to you.由你决定。 Or, if you implicitly trust all of the code you deploy with your function, you could get away with env vars.或者,如果您隐含地信任使用 function 部署的所有代码,则可以使用 env var。 And, if you are the only one with access to your source control, you could even put the values in there.而且,如果您是唯一可以访问源代码控制的人,您甚至可以将值放在那里。

You can see how everyone has a different security situation that requires different solutions.您可以看到每个人都有不同的安全情况,需要不同的解决方案。 Pick the one meets your particular needs.选择一个满足您的特定需求的。 But no solution is truly "completely safe" because someone or something must have access to your secrets, and that someone or something could be compromised in some way.但是没有解决方案是真正“完全安全”的,因为某人或某事必须有权访问您的秘密,并且某人或某事可能会以某种方式受到损害。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 带有 Firebase 数据库触发器的第二代 Google Cloud Functions - Google Cloud Functions 2nd Generation with Firebase Database trigger firebase 第 2 代的云函数 - Cloud functions for firebase generation 2 Github 第二代 Google Functions 的操作 - Github Actions to Google Functions 2nd gen 如何部署 Google Cloud Function(第 2 代)? - How do I deploy a Google Cloud Function (2nd generation)? 无法从第二代 AppEngine 中的请求 header 获取 X-AppEngine 信息 - can not get X-AppEngine info from req header in 2nd generation AppEngine Firebase RTDB:游标的第二个参数(startAt,endAt ...)究竟是如何工作的? - Firebase RTDB: How exactly the 2nd argument of cursors(startAt, endAt...) work? Firebase 身份验证失败,安全性为 null - Firebase Auth failing with null safety 云 function,第二代并发? - Cloud function, 2nd gen concurrency? 接收错误:html-pdf: PDF 生成超时。 Phantom.js 脚本没有退出。 Firebase 云函数内 - Receiving error: html-pdf: PDF generation timeout. Phantom.js script did not exit. within Firebase Cloud Functions 将谷歌云 function 2nd gen 连接到另一个项目的 mysql - Connect google cloud function 2nd gen to mysql of another project
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM