Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Command injection false positive with interpolated ternary #1223

Closed
bannable opened this issue May 31, 2018 · 1 comment
Closed

Command injection false positive with interpolated ternary #1223

bannable opened this issue May 31, 2018 · 1 comment

Comments

@bannable
Copy link

bannable commented May 31, 2018

Background

Brakeman version: 4.3.0 (pro)
Rails version: 3.2.22.8
Ruby version: 2.3.7p456

False Positive

Full warning from Brakeman:

Confidence: Medium
Category: Command Injection
Check: Execute
Code: system("echo #{f ? ("-n ") : ("")}")
File: lib/hello.rb
Line: 3

Relevant code:

def safe(f=false)
  system "echo #{f ? '-n ' : ''}"
end

Why might this be a false positive?

There is no user input to the system call. Interestingly, this also causes brakeman to miss this injection, and report only the ternary as a problem:

  def unsafe(file, f=false)
    system "echo #{f ? '-n ' : ''} < #{file}"
  end
@presidentbeef
Copy link
Owner

Hi Joe,

Thank you for reporting this issue and for the clear code examples. This was fixed on master with #1214.

Repository owner locked and limited conversation to collaborators Jul 14, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants