-
-
Notifications
You must be signed in to change notification settings - Fork 807
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
About default searchable attributes and associations #1273
Comments
I'm not sure why this default was left like that, I would be happy to change it to use more secure defaults, but it'd be nice to dig into issue/PR/commit history to figure out the reason (if any) first. |
I looked into it as best I could, but could not find a clear reason for not making the default secure. Although ransackable_attributes have been around since the very beginning, I don't think there has been any discussion since then towards making the default safe. |
I didn't look closely but are you sure 77e570c is related? |
My apologies. That was not an answer. I looked in issue/PR/commit to see why the default is the current behavior, but could not find it. |
I see. In 77e570c, when However the idea was somehow dropped at f151d62, leaving it completely to the application to provide its own secure defaults. I think we can add some configuration that applies to attributes of all models, and give it some reasonably safe default value, like Ransack.configure do |c|
c.non_searchable_attributes = [:encrypted_password, :password]
end |
I understand. |
I share OP's concern about the insecure default settings here. Proposals/Request for comments @deivid-rodriguez
|
Hei @lukas-eu, sorry for not replying earlier and not giving this issue the priority it deserves. And thanks for your great investigation of this issue! I essentially agree with your suggestions after reading about this problem a bit more. In particular I think we can go with some version of "2." above. I wrote https://github.com/activerecord-hackery/ransack/tree/improve-defaults that I think should satisfy both having secure defaults but also easily overriding those to relax them as wanted or even going back to the current behavior. The idea is that you need to explicitly provide explicit This would need proper documentation, and not sure if the implementation is ideal or will work properly in all cases, by do you think the idea makes sense? |
This looks great, I like it! Usually I would not be a fan of the easy override via a simple Two small suggestions:
I'll add a short note to our blog post when a new version with this behavior is released. |
I'm here from @lukas-eu's post, which is slowly filtering through social media. I strongly suggest going with option 2 in the proposed solution list: "Implement restrictive defaults (potentially allowing an explicit bypass)" and I think that this needs to be prioritized extremely highly. There are a lot of applications that are vulnerable here. The information is now public knowledge. In the default use-case a lot of people are likely sitting ducks. I would probably advocate for getting a CVE, issuing an update that changes the default, and providing detailed suggestions for people to fix their implementations. |
Thanks @lukas-eu. Sorry I didn't reply earlier today, too many things!
Me neither, this is what I dislike the most about the current approach. That just overwriting the method and delegating to
Fine with updating this, but maybe we should use something that suggest that it comes from
Makes sense I can give it a try. @hakusaro I'll release this ASAP as Ransack 3.0. |
That makes sense as well, collision safety is of course more important than aesthetics. I can't think of the perfect suggestion right now, maybe adding a |
@deivid-rodriguez do you mean 4.0? |
Yes, sorry! |
If you need any help with a github security advisory, I'd be more than happy to help you, too. If you go through github security advisories, you can get a GHSA ID and a CVE assigned, as well, which will expedite notification of potentially vulnerable people through scanning tools. |
@lukas-eu I think I mostly addressed the concerns at #1400:
Could you have a look at #1400 and let me know? |
Thanks everyone! @wonda-tea-coffee for raising the issue, @lukas-eu for digging in to this and making the problem visible via the blog post that went viral, and @deivid-rodriguez for your work on the gem and on providing a very neat solution. I especially like the new message that gives a copy/paste-able solution that makes visible what you expose and allows you to audit it easily. After reading the blog post last week I manually did a similar thing via the console, so I appreciate this solution being available as part of the gem. A lot of devs will appreciate its guidance when doing the upgrade. |
I left a review on #1400 :
|
Hei! As you may have noticed, I finally got around to releasing Ransack 4.0.0! Also we received an interesting report at #1403. It seems like a good idea to me, feel free to share your thoughts there! |
Great feature! But how about specific setting for disable it? I use strong parameters for filtering searching params and separate method in model looks like overthinking for me. |
I think you're aiming for #1403? I think it's a good idea, just needs someone to take a stab at it! |
for existing apps, what to do? Do we have to mention for every model? if we wanna only block passwords, nothing else. whats the best way ? |
I would be nice with a CVE. It does not seem like Dependabot is aware of the need to upgrade. |
Currently, if you don't restrict the searchable attributes and associations, you can search all ranges.
https://github.com/activerecord-hackery/ransack#authorization-whitelistingblacklisting
I feel that this is very dangerous.
My opinion is exactly the same as the following blog post.
https://younes.codes/posts/how-to-hack-with-ransack
I would like to make this gem secure by default.
Can you please tell me if there is a reason for the current way it is built? Also, I am willing to help if modifications are needed.
Many thanks.
The text was updated successfully, but these errors were encountered: