Skip to content

False Positive: command injection when escaped upstream. #1159

@envygeeks

Description

@envygeeks

Background

Brakeman version: ~> 4.1
Rails version: ~> 5.1
Ruby version: ~> 2.5

Link to Rails application code: No

Issue

When a variable is escaped upstream to a method, Brakeman claims that there could be command injection, even though it's escaped upstream in the initializer.

False Positive

Confidence: Medium
Category: Command Injection
Check: Execute
Message: Possible command injection
Code: `dig +short -x #{Shellwords.shellescape(ip)} @#{@mdns} -p #{@port}`
File: lib/blackhole/enumerators/mdns.rb
Line: 44

Relevant code:

class NotReadyForRelease
  def initialize(one, two)
    @one = Shellwords.shellescape(one)
    @two = Shellwords.shellescape(two)
  end

  def run(ip)
    ip = Shellwords.shellescape(ip)
    `dig +short -x #{ip} @#{@one} -p #{@two}`
  end
end

Why might this be a false positive?

Because it's escaped upstream of the method.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions