Skip to content

content_tag no longer considered dangerous #1778

@oreoshake

Description

@oreoshake

Background

Brakeman version: 5.1.2
Rails version: 6.1.7.3
Ruby version: 2.7.5

Link to Rails application code: #1778

False Positive

Full warning from Brakeman:

Confidence: High
Category: Cross-Site Scripting
Check: ContentTag
Message: Unescaped parameter value in `content_tag`
Code: content_tag(:tr, foo(mf), params[:foo] => params[:bar])

Relevant code:

helper.content_tag :p, "<script>alert(1)</script>", "<script>&'\"" => "<script>&'\""

Why might this be a false positive?

The return value seems to gsub out the control characters for _ in attribute names now.

=> "<p _script____=\"&lt;script&gt;&amp;&#39;&quot;\">&lt;script&gt;alert(1)&lt;/script&gt;</p>"

I haven't really tracked down when this changed. I thought I did, but no.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions