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

False positive dangerous send when using white list #1057

Closed
obfuscoder opened this Issue Jun 10, 2017 · 1 comment

Comments

Projects
None yet
2 participants
@obfuscoder

obfuscoder commented Jun 10, 2017

I use an early exit clause in my method whenever a parameter is not in the allowed whitelist before I try to use it in a method send call:

  def login
    goto = params[:goto]
    event = params[:event]
    return redirect_to user_path unless %w[comment subscribe].include?(goto)
    # additionally check event
    redirect_to send("#{goto}_event_path", event)
  end

This is still reported by brakeman as dangerous send. PR #640 does not cover this.

I know that I can use an if statement to let brakeman detect the white list exception. However as I do need to check the event additionally, this is not covered:

  def login
    goto = params[:goto]
    event = params[:event]
    if %w[comment subscribe].include?(goto) && event.present?
      redirect_to send("#{goto}_event_path", event)
    else
      redirect_to user_path
    end
  end

To let brakeman detect the whitelist, I would need to separate the conditions for white list and event checks:

  def login
    goto = params[:goto]
    event = params[:event]
    if %w[comment subscribe].include?(goto)
      if event.present?
        return redirect_to send("#{goto}_event_path", event)
      end
    end
    redirect_to user_path
  end

This is pretty ugly. So I would like to ask to let brakeman detecting early exit whitelisting.

@presidentbeef

This comment has been minimized.

Show comment
Hide comment
@presidentbeef

presidentbeef Jun 10, 2017

Owner

I agree...I have an idea of how to do this.

Owner

presidentbeef commented Jun 10, 2017

I agree...I have an idea of how to do this.

presidentbeef added a commit that referenced this issue Jun 24, 2017

Repository owner locked and limited conversation to collaborators Aug 7, 2017

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.