Giter Site home page Giter Site logo

False negative XSS about brakeman HOT 9 CLOSED

presidentbeef avatar presidentbeef commented on May 22, 2024
False negative XSS

from brakeman.

Comments (9)

presidentbeef avatar presidentbeef commented on May 22, 2024

This being caught depends on what @search is and how it is set.

from brakeman.

oreoshake avatar oreoshake commented on May 22, 2024

rails 2? 3? using rails_xss?

from brakeman.

philcox avatar philcox commented on May 22, 2024

Using Rails 235, no rails_xss. Looking at https://github.com/nzkoz/rails_xss

the params hash gets passed into @search it is initialized from the following code:

class SearchForm < OpenStruct

attr_reader :params

def initialize(data, param_name, *args)
data ||= {}
contents = {}
@params = {}

args.each do |item|
  contents[item]                    = data[item]
  @params["#{param_name}[#{item}]"] = data[item]
end

super(contents)

end

end

from brakeman.

presidentbeef avatar presidentbeef commented on May 22, 2024

Do you have an example of it being set in a controller?

This is only going to be caught if it's something like

def all
  @search = SearchForm.new(params, ...)
end

from brakeman.

philcox avatar philcox commented on May 22, 2024

Why will it only catch if called in a controller?

from brakeman.

presidentbeef avatar presidentbeef commented on May 22, 2024

Brakeman doesn't do whole program analysis (at least not at the moment, probably never since the Rails stack is huge), it looks at the regular Rails data flow from controllers to views, basically like a web request would do.

from brakeman.

philcox avatar philcox commented on May 22, 2024

so this is the controller action:
def index
params[:category] ||= default_category
@search = search_form(:s, :params => [ :category, :filter_type, :filter_value, :order, :advanced ])

and 'search_form' is a controller method defined as:
def search_form(param_name, opts = {})
SearchForm.new(params[param_name], param_name, *opts[:params])
end

from brakeman.

presidentbeef avatar presidentbeef commented on May 22, 2024

Okay. Brakeman is not going to look any further than @search = search_form(:s, :params => [ :category, :filter_type, :filter_value, :order, :advanced ]) (i.e., not into the body of search_form). That's why this is not raising a warning.

It's a limitation of Brakeman at the moment (it doesn't really do inter-procedural analysis), but I'm thinking about supporting "simple" helper methods like this.

from brakeman.

philcox avatar philcox commented on May 22, 2024

Got it. Thanks.

from brakeman.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.