Skip to content
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

Bad UTF-8 in GET body #14

Closed
ntalbott opened this issue Jul 7, 2014 · 1 comment · Fixed by #15
Closed

Bad UTF-8 in GET body #14

ntalbott opened this issue Jul 7, 2014 · 1 comment · Fixed by #15

Comments

@ntalbott
Copy link
Contributor

ntalbott commented Jul 7, 2014

The HTTP spec allows a GET body, and Rails violates the intent of the spec by parsing that body. Unfortunately this means that a poorly behaved bot (looking at you, EasuoSpider) that submits bad UTF-8 in a GET body throws exceptions even with utf8_sanitizer in place, since the sanitizer does not sanitize rack.input on GET.

For now I've fixed this locally via a custom middleware that just kills rack.input (by assigning StringIO.new) if the request is a GET, but I'm wondering if utf8_sanitizer should go ahead and sanitize rack.input on all requests, since the spec allows a body for all request types and someone out there could be relying on Rails parsing the body for GET.

Happy to submit a PR if you think this is a good idea, but I wanted to check first since I'm not sure what the overhead is on the IO sanitization.

@whitequark
Copy link
Owner

I definitely think it is a good idea.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants