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

update to rails unsafe reflection methods #3265

Merged
merged 3 commits into from
Jan 9, 2024

Conversation

normprovost
Copy link
Contributor

@normprovost normprovost commented Jan 5, 2024

👋 Hey team!

I believe I've identified a false positive here.

This rule was intended to match when user input was provided as an argument to the .tap method. Here's the relevant brakeman rule that this was related to: https://github.com/presidentbeef/brakeman/blob/main/lib/brakeman/checks/check_unsafe_reflection_methods.rb

What I found in practice was that this would match whenever object the .tap method was called ON as well. I ran into this with a bit of code that looked like this

  my_id = params[:id]
  my_new_object = MyObject.new(my_id)
  my_new_object.tap { |x| x.anything_here = 'asdf' }

In this case, the user input is not being passed in to the tap method, so I'm pretty sure there's no risk of unsafe reflection? I couldn't think of a way at least 🙃

Copy link
Contributor

@kurt-r2c kurt-r2c left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the changes themselves are good, however the nature of the implementation needs some fixes to avoid poor performance.

@0xDC0DE 0xDC0DE merged commit 138966d into semgrep:develop Jan 9, 2024
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants