Skip to content

Potential for arbitrary method invocation

High
hopsoft published GHSA-mp76-7w5v-pr75 Mar 14, 2024

Package

bundler turbo_boost-commands (RubyGems)

Affected versions

<=0.1.2, <= 0.2.1

Patched versions

0.1.3, 0.2.2

Description

Impact

TurboBoost Commands has existing protections in place to guarantee that only public methods on Command classes can be invoked; however, the existing checks aren't as robust as they should be. It's possible for a sophisticated attacker to invoke more methods than should be permitted depending on the the strictness of authorization checks that individual applications enforce. Being able to call some of these methods can have security implications.

Details

Commands verify that the class must be a Command and that the method requested is defined as a public method; however, this isn't robust enough to guard against all unwanted code execution. The library should more strictly enforce which methods are considered safe before allowing them to be executed.

Patches

Patched in the following versions.

Workarounds

You can add this guard to mitigate the issue if running an unpatched version of the library.

class ApplicationCommand < TurboBoost::Commands::Command
  before_command do
    method_name = params[:name].include?("#") ? params[:name].split("#").last : :perform
    ancestors = self.class.ancestors[0..self.class.ancestors.index(TurboBoost::Commands::Command) - 1]
    allowed = ancestors.any? { |a| a.public_instance_methods(false).any? method_name.to_sym }
    throw :abort unless allowed # ← blocks invocation
    # raise "Invalid Command" unless allowed # ← blocks invocation
  end
end

Severity

High

CVE ID

CVE-2024-28181

Weaknesses

No CWEs