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

Failing for garbage(URL encoded) value in query parameter #268

Open
mnj93 opened this issue May 15, 2020 · 1 comment
Open

Failing for garbage(URL encoded) value in query parameter #268

mnj93 opened this issue May 15, 2020 · 1 comment

Comments

@mnj93
Copy link

mnj93 commented May 15, 2020

I'm facing an issue with Request validation middleware.
I've following schema for one of my GET API endpoint

schema" : {
              "maxLength" : 10,
              "pattern" : "^[A-Z]+$",
              "type" : "string",
              "example" : "ABCDEF"
            }

This is working fine for normal scenarios when I pass something like ABCDEFS or 123 it's giving expected output with error and status code of 4xx.

If I pass value like %2f%2e%2e%c0%af%2e%2e%2f%2e%2e%c0%af%2e%2e%2f%2e%2e%c0%af%2e%2e%2f%2e%2e%c0%af%2e%2e%2f%2e%2e%c0%af%2e%2e%2f%2e%2e%c0%af%2e%2e%2fetc%2fshadow then it's failing with status code of 5xx with error invalid byte sequence in UTF-8.

This should have returned a response like other invalid values but it's returning 5xx.

@ota42y
Copy link
Member

ota42y commented Jun 3, 2020

This parameter return 400 abc+ZZZ%2F.

And I tried parse your value by pure ruby code and get error...
What value are you sending? Probably it can not be processed by ruby ​​regular expression as it is.

require 'cgi'
CGI.unescape("%2f%2e%2e%c0%af%2e%2e%2f%2e%2e%c0%af%2e%2e%2f%2e%2e%c0%af%2e%2e%2f%2e%2e%c0%af%2e%2e%2f%2e%2e%c0%af%2e%2e%2f%2e%2e%c0%af%2e%2e%2fetc%2fshadow") =~ /abc/
=> ArgumentError (invalid byte sequence in UTF-8)

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

No branches or pull requests

2 participants