snowdrop-zen / quarkus

Quarkus: Supersonic Subatomic Java.
https://quarkus.io
Apache License 2.0
1 stars 0 forks source link

NPE thrown in X-Forwarded-For header parsing #246

Closed snowdrop-bot closed 3 years ago

snowdrop-bot commented 3 years ago

Describe the bug I got the following error and stack trace reported when a request was sent with the following header X-Forwarded-For: 10.17.13.17. I don't know for sure if this is the header which caused the problem, that is just my assumption. I am however quite sure this problem didn't exist before Quarkus 1.11.0.Final.

21:05:51.537 ERROR [io.qu.ve.ht.ru.QuarkusErrorHandler] (executor-thread-8) HTTP Request to null failed, error id: 45a1b57a-7a5f-46d2-9dd6-c00d237c5c5a-1: java.lang.NullPointerException
    at io.quarkus.vertx.http.runtime.ForwardedParser.parseHostAndPort(ForwardedParser.java:199)
    at io.quarkus.vertx.http.runtime.ForwardedParser.setHostAndPort(ForwardedParser.java:181)
    at io.quarkus.vertx.http.runtime.ForwardedParser.calculate(ForwardedParser.java:108)
    at io.quarkus.vertx.http.runtime.ForwardedParser.absoluteURI(ForwardedParser.java:85)
    at io.quarkus.vertx.http.runtime.ForwardedServerRequestWrapper.absoluteURI(ForwardedServerRequestWrapper.java:214)
    at io.vertx.ext.web.impl.HttpServerRequestWrapper.absoluteURI(HttpServerRequestWrapper.java:234)
    at io.quarkus.resteasy.runtime.standalone.VertxUtil.extractUriInfo(VertxUtil.java:31)
    at io.quarkus.resteasy.runtime.standalone.VertxRequestHandler.dispatch(VertxRequestHandler.java:120)
    at io.quarkus.resteasy.runtime.standalone.VertxRequestHandler.access$000(VertxRequestHandler.java:41)
    at io.quarkus.resteasy.runtime.standalone.VertxRequestHandler$1.run(VertxRequestHandler.java:93)
    at org.jboss.threads.EnhancedQueueExecutor$Task.run(EnhancedQueueExecutor.java:2415)
    at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1452)
    at org.jboss.threads.DelegatingRunnable.run(DelegatingRunnable.java:29)
    at org.jboss.threads.ThreadLocalResettingRunnable.run(ThreadLocalResettingRunnable.java:29)
    at java.base/java.lang.Thread.run(Unknown Source)
    at org.jboss.threads.JBossThread.run(JBossThread.java:501)

Expected behavior Probably the header should be ignored and a message be logged.

Actual behavior NPE logged and 500 status error result.

To Reproduce

Configuration

quarkus.http.proxy.proxy-address-forwarding=true
quarkus.http.proxy.enable-forwarded-host=true

Environment (please complete the following information):


https://github.com/quarkusio/quarkus/issues/14536


$upstream:14536$