Skip to content

Commit

Permalink
fix(ruby): add missing rails XSS send_data case (#356)
Browse files Browse the repository at this point in the history
  • Loading branch information
didroe authored Apr 2, 2024
1 parent ec09c22 commit e001462
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 0 deletions.
5 changes: 5 additions & 0 deletions rules/ruby/rails/render_using_user_input.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ patterns:
- variable: USER_INPUT
detection: ruby_shared_common_html_user_input
scope: result
- pattern: send_data($<USER_INPUT>$<...>)
filters:
- variable: USER_INPUT
detection: ruby_shared_common_html_user_input
scope: result
severity: high
metadata:
description: "Unsanitized user input in raw HTML strings (XSS)"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@

render html: sanitize(params[:oops])
render inline: "<h1>#{strip_tags(params[:oops])}</h1>"

send_data "ok", type: content_type
3 changes: 3 additions & 0 deletions tests/ruby/rails/render_using_user_input/testdata/unsafe.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,6 @@
render html: params[:oops]
# bearer:expected ruby_rails_render_using_user_input
render inline: "<h1>#{params[:oops]}</h1>"

# bearer:expected ruby_rails_render_using_user_input
send_data params[:oops], type: content_type

0 comments on commit e001462

Please sign in to comment.