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

CRLF injection via new line characters in URI #237

Closed
samwcyo opened this issue Jan 24, 2019 · 5 comments
Closed

CRLF injection via new line characters in URI #237

samwcyo opened this issue Jan 24, 2019 · 5 comments
Assignees

Comments

@samwcyo
Copy link

samwcyo commented Jan 24, 2019

Summary
pypiserver doesn't escape new line characters when redirecting users. I'm not too sure if this is only in the default installation, or that if users used a redirect functionality it would additionally be vulnerable.

Steps to Reproduce

  1. Download pypiserver and host a default installation
  2. Open http://pypiserver/%0d%0aSet-Cookie:malicious=1;
  3. Observe cookie being set

Impact
Create arbitrary HTTP responses, set malicious cookies, potential for XSS depending on implementation (i.e. location header doesn't redirect to a valid host and therefore displays whatever content is available)

@mplanchard
Copy link
Contributor

Thanks for the report! I'll look into this and try to get it fixed ASAP.

mplanchard added a commit that referenced this issue Jan 24, 2019
Resolves #237

Previously, we were not running any sort of URL escaping on values
passed in from the client that were used for redirects. This allowed
injection attacks via URL encoded newlines in the original request.

This update ensures that all user-supplied paths that are used as
components of redirects are passed through `urllib.parse.quote()`
(or the python 2 equivalent) prior to being used in a redirect
response.
mplanchard added a commit that referenced this issue Jan 24, 2019
Resolves #237

Previously, we were not running any sort of URL escaping on values
passed in from the client that were used for redirects. This allowed
injection attacks via URL encoded newlines in the original request.

This update ensures that all user-supplied paths that are used as
components of redirects are passed through `urllib.parse.quote()`
(or the python 2 equivalent) prior to being used in a redirect
response.

Also specified 127.0.0.1 rather than 0.0.0.0 (the default) in server
tests to avoid triggering firewall dialogs when testing on MacOS
@mplanchard
Copy link
Contributor

#238 I think should resolve this. At least it fixes it when running locally for me, on python 2 and 3. Could you take a look and see what you think, if you've got time?

@samwcyo
Copy link
Author

samwcyo commented Jan 25, 2019

Resolved for me! Cheers.

@samwcyo samwcyo closed this as completed Jan 25, 2019
@Prathapdhanapal
Copy link

Pixel quality

1 similar comment
@Prathapdhanapal
Copy link

Pixel quality

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

No branches or pull requests

4 participants
@mplanchard @samwcyo @Prathapdhanapal and others