martoncsukas
martoncsukas

Reputation: 2165

`ERR_HTTP2_PROTOCOL_ERROR` when pipe character (|) in GET request query parameter in Wildfly 21

We've recently migrated a Spring REST application from Wildfly 15.0.1.Final to Wildfly 21.0.0.Final which apparently introduced an issue with GET requests: whenever we have a | (pipe) character in the query parameter string of the GET request, the request returns no response and we get ERR_HTTP2_PROTOCOL_ERROR.

I know that '|' (pipe) character is unsafe according to the RFC1738 specification of HTTP, while RFC3986 allows for the encoding of Unicode characters.

I would like this to keep working though, as we have external clients sending requests with | character in the query parameter, and currently if we would move to the current Wildfly 21 config, those requests would fail.

The same configuration was working fine on Wildfly 15.0.1.Final.

I have these in standalone.xml with no avail:

 <system-properties>
      <property name="org.apache.catalina.connector.URI_ENCODING" value="UTF-8"/>
      <property name="org.apache.catalina.connector.USE_BODY_ENCODING_FOR_QUERY_STRING" value="true"/>
 </system-properties>
<http-listener name="default" socket-binding="http" allow-unescaped-characters-in-url="true" redirect-socket="https" enable-http2="true" url-charset="UTF-8" />
<https-listener name="https" socket-binding="https" max-post-size="1048576000" allow-unescaped-characters-in-url="true" ssl-context="LocalhostSslContext" enable-http2="true" url-charset="UTF-8" />

...and this in standalone.conf.bat:

set "JAVA_OPTS=%JAVA_OPTS% -Dorg.apache.catalina.connector.URI_ENCODING=UTF-8"

The very same code on the very same VM, with (migrated) config works fine on Wildfly 15.0.1.Final but throws the ERR_HTTP2_PROTOCOL_ERROR in Wildfly 21.0.0.Final whenever I have a | in the request. In these cases it looks like the request is not even hitting my breakpoints.

I can programmatically do a dirty fix by URL encoding all | in our $.ajaxSetup, but this only fixes requests originating from the server itself, and not requests that are coming externally with | in their GET request query params.

The dirty (and insufficient) fix:

  $.ajaxSetup({
    beforeSend: function (jqXHR, settings) {
      settings.url = settings.url.replace(/\|\|/g, "%7C%7C");
    }
  });

Has anyone encountered this issue?

Full standalone.xml (with sensitivre info masked) here.

EDIT: In the meantime I noticed that this issue only happens when I hit endpoints defined in Windows hosts file. When I go through our company's load balancer, it works fine.

So e.g. http://localhost.myproduct.com is not working from SERVER1 if 127.0.0.1 localhost.myproduct.com is in hosts file, but https://server1.myproduct.com that hits the very same server works fine, if the endpoint is routed through the load balancer.

Upvotes: 1

Views: 1114

Answers (1)

dsmith1547
dsmith1547

Reputation: 31

I saw a few related postings around this time, all of which seem to have gone unanswered.

I've also encountered a similar issue with Wildfly 23.0.0.Final, which was a problem with http/2 handling - there is a fix for that: UndertowOptions.ALLOW_UNESCAPED_CHARACTERS_IN_URL has no effect for HTTP/2, but as of this reply AFAIK is not yet released in a Wildfly build.

Setting enable-http2="false" on the listeners - while not ideal - worked around the problem for me.

It could be that your load balancer is doing http/1.1 on the backend which would be why you don't encounter the problem when routing through it.

Upvotes: 3

Related Questions