labml icon indicating copy to clipboard operation
labml copied to clipboard

Associations not considered as AR objects

Open grosser opened this issue 6 years ago • 7 comments

Background

Brakeman version: 4.3.1 Rails version: 5.2.0 Ruby version: 2.5.1

<%= @project.repositories.first.name.html_safe %>

Issue

should have alerted of xss

/cc @smo921

grosser avatar Aug 11 '18 00:08 grosser

This really depends on what @project is and if Brakeman thinks it's a database model.

To reproduce or fix this issue, I'd need to know how the template is being rendered and what Brakeman thinks the output is. Can you run with --debug and check the template output? See if it's being rendered and what the value is?

presidentbeef avatar Aug 13 '18 19:08 presidentbeef

under projects/show I can see:

[Escaped Output] @project.repositories.first.name.html_safe

so I doubt it did anything smart 🤷‍♂️

grosser avatar Aug 22 '18 15:08 grosser

Right, so the next question is "why not?" Where is the @project value set?

presidentbeef avatar Aug 22 '18 15:08 presidentbeef

ah ... it works when it's directly in the controller but not when it's in the parent

grosser avatar Aug 22 '18 15:08 grosser

it would be interesting to say "you have to whitelist unknown instance vars or they are considered models" so I would have been notified that the class of @project is unknown

grosser avatar Aug 22 '18 15:08 grosser

ah ... it works when it's directly in the controller but not when it's in the parent

I'm not sure what this means? If the variable is set in a before_action it should be picked up. Otherwise if it's in a helper method, it won't. Or are you calling super in a controller action?

presidentbeef avatar Aug 24 '18 21:08 presidentbeef

action is in the parent controller and not in the child controller

On Fri, Aug 24, 2018 at 2:31 PM Justin [email protected] wrote:

ah ... it works when it's directly in the controller but not when it's in the parent

I'm not sure what this means? If the variable is set in a before_action it should be picked up. Otherwise if it's in a helper method, it won't. Or are you calling super in a controller action?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/presidentbeef/brakeman/issues/1250#issuecomment-415887925, or mute the thread https://github.com/notifications/unsubscribe-auth/AAAsZ_yBUZPxrsNEBg8rJiBMd0NhyJ0Fks5uUHC-gaJpZM4V49gQ .

grosser avatar Aug 24 '18 22:08 grosser