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

Forwarded header is not parsed as expected #25225

Closed
ejba opened this issue Apr 28, 2022 · 1 comment · Fixed by #25226
Closed

Forwarded header is not parsed as expected #25225

ejba opened this issue Apr 28, 2022 · 1 comment · Fixed by #25226
Labels
kind/bug Something isn't working
Milestone

Comments

@ejba
Copy link
Contributor

ejba commented Apr 28, 2022

Describe the bug

According to RFC7239, the Forwarded header can have a comma-separated list of values. It is used to indicate the string of proxies (including the client that initiated the request).

The ForwardedParser class splits this header by comma and later considers only the first element. This element will be the one that will determine each property of the request (protocol, host, etc). This is not the expected behavior as it will discard the remaining information in the header, as you will see in the next sections.

Expected behavior

When a client does a HTTP request with the following header, Forwarded: by=proxy;for=backend:4444,for=backend2:5555;host=somehost;proto=https, the quarkus server must consider host and proto properties defined by the header.

Actual behavior

The properties host and proto are not considered, and eventually discarded.

How to Reproduce?

    @Test
    public void testForwardedForWithSequenceOfProxies() {
        assertThat(RestAssured.get("/forward").asString()).startsWith("http|");

        RestAssured.given()
                .header("Forwarded", "by=proxy;for=backend:4444,for=backend2:5555;host=somehost;proto=https")
                .get("/forward")
                .then()
                .body(Matchers.equalTo("https|somehost|backend:4444"));
    }

Output of uname -a or ver

Darwin dibss-MacBook-Pro.local 21.4.0 Darwin Kernel Version 21.4.0: Fri Mar 18 00:45:05 PDT 2022; root:xnu-8020.101.4~15/RELEASE_X86_64 x86_64

Output of java -version

openjdk version "11.0.15" 2022-04-19 OpenJDK Runtime Environment Temurin-11.0.15+10 (build 11.0.15+10) OpenJDK 64-Bit Server VM Temurin-11.0.15+10 (build 11.0.15+10, mixed mode)

GraalVM version (if different from Java)

No response

Quarkus version or git rev

No response

Build tool (ie. output of mvnw --version or gradlew --version)

Apache Maven 3.8.4 (9b656c72d54e5bacbed989b64718c159fe39b537)

Additional information

No response

@ejba
Copy link
Contributor Author

ejba commented Apr 28, 2022

/cc @sberyozkin @luneo7

@quarkus-bot quarkus-bot bot added this to the 2.10 - main milestone Apr 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant