CVE-2015-7551:Fiddle 和 DL 中不安全的使用受污染的字符串

Fiddle 和 DL 中存在不安全的使用受污染字符串的漏洞。此漏洞已被分配 CVE 标识符 CVE-2015-7551

详情

Fiddle 和 DL 中存在不安全的使用受污染字符串的漏洞。此问题最初在 DL 中通过 CVE-2009-5147 报告并修复,但在 DL 使用 Fiddle 和 libffi 重新实现后再次出现。

并且,关于 DL,CVE-2009-5147 在 Ruby 1.9.1 中已修复,但在其他分支中未修复,因此捆绑了 DL 的 Ruby 版本(除了 Ruby 1.9.1)仍然容易受到攻击。

受影响的代码看起来像这样

handle = Fiddle::Handle.new(dangerous_user_input)

handle = Fiddle::Handle.new(some_library)
function_pointer = handle[dangerous_user_input]

所有运行受影响版本的用户应立即升级或使用其中一种解决方法。

受影响的版本

  • Ruby 1.9.2 和 Ruby 1.9.3 的所有补丁版本(DL 和 Fiddle)。
  • Ruby 2.0.0 在 Ruby 2.0.0 patchlevel 648 之前的所有补丁版本(DL 和 Fiddle)。
  • Ruby 2.1 在 Ruby 2.1.8 之前的所有版本(DL 和 Fiddle)。
  • Ruby 2.2 在 Ruby 2.2.4 之前的所有版本(Fiddle)。
  • Ruby 2.3.0 preview 1 和 preview 2(Fiddle)。
  • trunk revision 53153 之前的版本(Fiddle)。

解决方法

如果无法升级,可以应用以下猴子补丁作为 Fiddle 的解决方法

class Fiddle::Handle
  alias :old_initialize :initialize

  def initialize file, *args
    raise SecurityError if file.tainted? && $SAFE > 0
    old_initialize file, *args
  end

  alias :sym :[]
  alias :old_call :[]

  def [] fun
    raise SecurityError if fun.tainted? && $SAFE > 0
    old_call fun
  end
end

如果您正在使用 DL,请使用 Fiddle 代替它。

致谢

感谢 Christian Hofstaedtler [email protected] 报告此问题!

历史

  • 最初发布于 2015-12-16 12:00:00 UTC