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

Use strict Base64 encoding to prevent bad requests #12

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

stewartpark
Copy link

With Array#pack, if the credentials is too long, it ends up adding a
new line in the middle of the resulting base64 encoded string, which results in
a 400 Bad Request. To fix this, Base64.strict_encode64 should be used.

Bad:

CONNECT blah:80 HTTP/1.1
Proxy-Authorization: Basic YWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhOmJiYmJiYmJiYmJiYmJi
YmJiYmJi
...

Good:

CONNECT blah:80 HTTP/1.1
Proxy-Authorization: Basic YWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhOmJiYmJiYmJiYmJiYmJiYmJiYmJi
...

With `Array#pack`, if the credentials is too long, it ends up adding a
new line in the middle of the base64 encoded string, which results in
a 400 Bad Request. To fix this, `Base64.strict_encode64` is now used.
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.

1 participant