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

Fail fast for long g-responses #309

Merged
merged 1 commit into from
Apr 1, 2019
Merged

Fail fast for long g-responses #309

merged 1 commit into from
Apr 1, 2019

Conversation

yifeiwu
Copy link
Contributor

@yifeiwu yifeiwu commented Apr 1, 2019

Submitting a verify request with a long (~4000) g-recaptcha-response will cause the endpoint to return a 400 error instead of a 200 response with a json body. For even larger payloads, this will return a 413 error.

This causes an error in the reply parsing since we're expecting a json response. https://github.com/ambethia/recaptcha/blob/master/lib/recaptcha/verify.rb#L79

Verifying this from https://www.google.com/recaptcha/api2/demo, the actual g-recaptcha-response should only be ~335 characters long.

Duplication

Make a request with 4095 characters in the response parameter. Note doing this this in browsers may truncate the request.

https://www.google.com/recaptcha/api/siteverify?secret=YOURSECRETHERE&response=unexisting/../../../../../../../../../../windows/win.ini.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.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\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\..\.\.\.\.\.\..\.\.\.\.\.\.

@grosser
Copy link
Collaborator

grosser commented Apr 1, 2019

kinda makes sense ... would also be good to return false when the response is not 200 / not json and maybe log an error

@grosser grosser merged commit 92bec04 into ambethia:master Apr 1, 2019
@grosser
Copy link
Collaborator

grosser commented Apr 1, 2019

4.14.0

@yifeiwu
Copy link
Contributor Author

yifeiwu commented Apr 1, 2019

Danke

@grosser
Copy link
Collaborator

grosser commented Apr 1, 2019

Bitteschön :D

@theirix theirix mentioned this pull request Mar 5, 2022
1 task
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 this pull request may close these issues.

2 participants