每次调用都可自动下载并执行未固定版本的 npm 包
原文依据:2 处说明强制使用 `npx -y firebase-tools@latest`。`@latest` 不固定经过审查的版本,`-y` 自动接受安装;因此即使只是查询版本,也可能从包源下载并执行新代码。登录后运行时,该代码还处于可访问 Firebase 凭据的环境中。
若上游包、发布账户或依赖链被入侵,恶意代码可能读取本机文件或会话凭据,并以当前用户权限执行。提供的证据不表示这种入侵已经发生。
来源支持这一风险:该技能强制使用带 `-y` 的 `@latest` 包,而登录步骤会在同一环境中建立 Firebase 身份。随后运行未固定版本的 CLI 时,它可能接触本地登录状态及获准的 Firebase 项目。这里没有证据证明凭据已被滥用;风险条件是用户实际执行这些命令。用户可固定版本,并用低权限账号或隔离环境运行。
1. **Use npx for CLI commands:** To ensure you always use the latest version of the Firebase CLI, always prepend commands with `npx -y firebase-tools@latest` instead of just `firebase`. For example, use `npx -y firebase-tools@latest --version`. NEVER suggest the naked `firebase` command as an alternative.1. **Prioritize official knowledge:** For any Firebase-related knowledge,查看另外 1 个位置
1. **Authentication:** Ensure you are logged in to Firebase so that commands have the correct permissions. Run `npx -y firebase-tools@latest login`. For environments without a browser (e.g., remote shells), use `npx -y firebase-tools@latest login --no-localhost`. - The command should output the current user. - If you are not logged in, follow the interactive instructions from this command to authenticate.