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

Receiving X-Forwarded-Port header containing anything else than a number breaks the servlet #1385

Open
mormegil-cz opened this issue May 12, 2021 · 2 comments

Comments

@mormegil-cz
Copy link

When a request containing a HTTP header X-Forwarded-Port, containing anything else than a valid int value (like… e.g. two port numbers separated by a comma, “443,80”), an exception is thrown and the servlet does not work.

See

where the header value is unconditionally parsed using Integer.parseInt which throws on any non-int input, with the exception not being caught.

This is wrong, 1. The header is nonstandard, you cannot assume its format in such a strict way. 2. Our infrastructure/microservice architecture causes the requests to pass through multiple layers of proxies/LBs, with the final request containing a list of forwarding agents in the X-Forwarded- headers (cf. MDN’s description of X-Forwarded-For). And… restlet crashes when multiple port numbers are received in the X-Forwarded-Port header.

You might want to extract a single (welll… the first one? the last one?) value from the list? But anyway, never crash on receiving an invalid non-standard header (not even for X-Forwarded-Port: foo,bar,?).

@thboileau
Copy link
Contributor

Hi @mormegil-cz can you tell us which version of the framework are you using?

@mormegil-cz
Copy link
Author

2.3.12

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

3 participants