### 关键信息 #### 漏洞概述 - **CVE ID**: CVE-2016-7954 - **影响范围**: Bundler的所有稳定版本 - **漏洞描述**: 攻击者可以通过gemfile中声明的任何次要gems源注入任意代码,无论该源是否限定了特定gems。 #### 示例 ```markdown source "http://public.org" source "http://private.com" gem "foo" gem "bar" gem "baz" ``` #### 源模糊警告 - **问题**: 当gem可以从多个源安装时,Bundler会显示警告,提示用户限制gem的源。 - **解决方案**: 使用`:source`选项或源块。 #### `:source`选项 - **尝试使用`:source`选项**: ```markdown source "http://public.org" gem "foo" gem "bar", source: "http://private.com" gem "baz" ``` - **实际效果**: 所有三个gem都从次要源安装。 #### 源块 - **使用源块**: ```markdown source "http://public.org" gem "newcomb" source "http://private.com" do gem "fair_dice_roll" end gem "insecure_random" ``` - **实际效果**: 同样未能解决源模糊问题。 #### 保护措施 - **使用多源块**: 目前唯一确保gems从预期源安装的方法是将每个gem声明放在其自己的源块中。 #### 修复Bundler - **报告日期**: 2016年4月1日 - **修复情况**: 已在Bundler 2开发中修补,但不计划回溯到Bundler 1,因需向后不兼容更改。