Skip to content

NPE in WriteFlusher after org.eclipse.jetty.http.BadMessageException: 417 #13583

@shraddha-g1

Description

@shraddha-g1

Jetty version(s)
12.0.22

Jetty Environment
ee10

Java version/vendor (use: java -version)
any

OS type/version
any
Description
Our service has a public URL and gets a malicious request, after which Jetty starts the parsing and we see the log

message: parsedHeader(Accept-Encoding: gzip, deflate, br) header=Accept-Encoding, headerString=[Accept-Encoding], valueString=[gzip, deflate, br]
message: HEADER:IN_VALUE --> FIELD(Accept-Encoding: gzip, deflate, br: gzip, deflate, br)
message: parsedHeader(Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8) header=Accept, headerString=[Accept], valueString=[text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8]

This causes a NPE in WriteFlusher which leads to the jetty server abruptly closing the connection

logger: org.eclipse.jetty.io.WriteFlusher
   message: ignored: java.lang.NullPointerException WriteFlusher@551ee3d2{IDLE}->null

Adding logs in detail here

logger: org.eclipse.jetty.server.handler.ErrorHandler
   message: handle(ErrorRequest@6659c805:GET@1591f7ec http://{our-site}/sitemap.xml?waqln=edyst HTTP/1.1, ErrorResponse@3b19d1b6{417,GET@1591f7ec http://{our-site}//sitemap.xml?waqln=edyst HTTP/1.1}, ErrorCallback@1f32cc46)
message: doClose SocketChannelEndPoint@1374874[{l=/127.0.0.1:7442,r=/127.0.0.1:36594,CLOSED,fill=-,flush=-,to=1/30000}{io=0/0,kio=0,kro=1}]->[HttpConnection@5d9ec959[p=HttpParser{s=CONTENT,0 of 94},g=HttpGenerator@e2ddb41{s=START}]=>HttpChannelState@35624618{handling=null, handled=false, send=SENDING, completed=true, request=GET@1591f7ec http://{our-site}/sitemap.xml?waqln=edyst HTTP/1.1}]
logger: org.eclipse.jetty.io.AbstractEndPoint
   message: close(java.lang.NullPointerException) SocketChannelEndPoint@1374874[{l=/127.0.0.1:7442,r=/127.0.0.1:36594,OPEN,fill=-,flush=-,to=1/30000}{io=0/0,kio=0,kro=1}]->[HttpConnection@5d9ec959[p=HttpParser{s=CONTENT,0 of 94},g=HttpGenerator@e2ddb41{s=START}]=>HttpChannelState@35624618{handling=null, handled=false, send=SENDING, completed=true, request=GET@1591f7ec http://{our-site}/sitemap.xml?waqln=edyst HTTP/1.1}]
exception: org.eclipse.jetty.http.BadMessageException: 417: null
	at o.e.j.s.i.HttpConnection$HttpStreamOverHTTP1.headerComplete(HttpConnection.java:1307)
	at o.e.j.s.i.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:984)
	at o.eclipse.jetty.http.HttpParser.parseFields(HttpParser.java:1365)
	at o.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:1661)
	at o.e.j.s.internal.HttpConnection.parseRequestBuffer(HttpConnection.java:584)
	at o.e.j.s.internal.HttpConnection.onFillable(HttpConnection.java:384)
	at o.e.j.i.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:322)
	at [o.eclipse.jetty.io](http://o.eclipse.jetty.io/).FillInterest.fillable(FillInterest.java:99)
	at o.e.j.i.SelectableChannelEndPoint$1.run(SelectableChannelEndPoint.java:53)
	at o.e.j.u.t.s.AdaptiveExecutionStrategy.runTask(AdaptiveExecutionStrategy.java:480)
	at o.e.j.u.t.s.AdaptiveExecutionStrategy.consumeTask(AdaptiveExecutionStrategy.java:443)
	at o.e.j.u.t.s.AdaptiveExecutionStrategy.tryProduce(AdaptiveExecutionStrategy.java:293)
	at o.e.j.u.t.s.AdaptiveExecutionStrategy.run(AdaptiveExecutionStrategy.java:201)
	at o.e.j.u.t.ReservedThreadExecutor$ReservedThread.run(ReservedThreadExecutor.java:311)
	at o.e.j.u.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:981)
	at o.e.j.u.t.QueuedThreadPool$Runner.doRunJob(QueuedThreadPool.java:1211)
	at o.e.j.u.t.QueuedThreadPool$Runner.run(QueuedThreadPool.java:1166)
	at java.base/java.lang.Thread.run(Thread.java:840)
	Suppressed: org.eclipse.jetty.util.StaticException: Unconsumed request content
   gusId: a6f000000000001
logger: org.eclipse.jetty.util.ConcurrentPool
   message: released true ConcurrentEntry@215131f{terminated=false,multiplex=0,pooled=Buffer@116a400a[rc=0,DirectByteBuffer@1b65cb0a[p=0,l=0,c=8192,r=0]={<<<>>>GET /site...JhbGciO}]} for ConcurrentPool@22660eff[strategy=THREAD_ID,inUse=0,size=42,max=256,leaked=0,terminated=false]
ogger: org.eclipse.jetty.server.internal.HttpConnection
   message: caught exception HttpConnection@5d9ec959::SocketChannelEndPoint@1374874[{l=/127.0.0.1:7442,r=/127.0.0.1:36594,OPEN,fill=-,flush=-,to=1/30000}{io=0/0,kio=0,kro=1}]->[HttpConnection@5d9ec959[p=HttpParser{s=CONTENT,0 of 94},g=HttpGenerator@e2ddb41{s=START}]=>HttpChannelState@35624618{handling=null, handled=false, send=SENDING, completed=true, request=GET@1591f7ec http://c{our-site}//sitemap.xml?waqln=edyst HTTP/1.1}] HttpChannelState@35624618{handling=null, handled=false, send=SENDING, completed=true, request=GET@1591f7ec http://{our-site}//sitemap.xml?waqln=edyst HTTP/1.1}
message: consuming content during error org.eclipse.jetty.util.StaticException: Unconsumed request content
logger: org.eclipse.jetty.server.internal.HttpChannelState
   message: failing request not yet handled GET@1591f7ec http:/{our-site}/sitemap.xml?waqln=edyst HTTP/1.1 HttpChannelState@35624618{handling=null, handled=false, send=SENDING, completed=false, request=GET@1591f7ec http://{our-site}/sitemap.xml?waqln=edyst HTTP/1.1} (edited)
message: Destroyed SocketChannelEndPoint@1374874[{l=null,r=null,CLOSED,fill=-,flush=-,to=2/30000}{io=0/0,kio=-1,kro=-1}]->[HttpConnection@5d9ec959[p=HttpParser{s=CONTENT,0 of 94},g=HttpGenerator@e2ddb41{s=START}]=>HttpChannelState@35624618{handling=null, handled=false, send=LAST_SENDING, completed=true, request=GET@1591f7ec http://{our-site}/sitemap.xml?waqln=edyst HTTP/1.1}]
message: onFillable exit HttpChannelState@35624618{handling=null, handled=false, send=LAST_SENDING, completed=true, request=GET@1591f7ec http://{our-site}//sitemap.xml?waqln=edyst HTTP/1.1} null HttpConnection@5d9ec959::SocketChannelEndPoint@1374874[{l=null,r=null,CLOSED,fill=-,flush=-,to=1/30000}{io=0/0,kio=-1,kro=-1}]->[HttpConnection@5d9ec959[p=HttpParser{s=CONTENT,0 of 94},g=HttpGenerator@e2ddb41{s=START}]=>HttpChannelState@35624618{handling=null, handled=false, send=LAST_SENDING, completed=true, request=GET@1591f7ec http://c{our-site}//sitemap.xml?waqln=edyst HTTP/1.1}]
message: queue [org.eclipse.jetty.io](http://org.eclipse.jetty.io/).ManagedSelector$DestroyEndPoint@14254f22 startThread=0
message: recycling HttpChannelState@35624618{handling=null, handled=false, send=LAST_COMPLETE, completed=true, request=GET@1591f7ec http://{our-site}//sitemap.xml?waqln=edyst HTTP/1.1}
message: close(org.eclipse.jetty.http.BadMessageException: 417: null) SocketChannelEndPoint@1374874[{l=null,r=null,CLOSED,fill=-,flush=F,to=3/30000}{io=0/0,kio=-1,kro=-1}]->[HttpConnection@5d9ec959[p=HttpParser{s=CONTENT,0 of 94},g=HttpGenerator@e2ddb41{s=COMPLETING}]=>HttpChannelState@35624618{handling=null, handled=false, send=LAST_COMPLETE, completed=true, request=GET@1591f7ec http://{our-site}/sitemap.xml?waqln=edyst HTTP/1.1}]
exception: java.nio.channels.ClosedChannelException: null
	at [j.b.nio.ch](http://j.b.nio.ch/).SocketChannelImpl.ensureOpenAndConnected(SocketChannelImpl.java:215)
	at [j.b.nio.ch](http://j.b.nio.ch/).SocketChannelImpl.write(SocketChannelImpl.java:558)
	at j.b.nio.channels.SocketChannel.write(SocketChannel.java:642)
	at [o.e.j.io](http://o.e.j.io/).SocketChannelEndPoint.flush(SocketChannelEndPoint.java:112)
	... 21 common frames omitted
Wrapped by: org.eclipse.jetty.io.EofException: null
	at [o.e.j.io](http://o.e.j.io/).SocketChannelEndPoint.flush(SocketChannelEndPoint.java:118)
	at [o.eclipse.jetty.io](http://o.eclipse.jetty.io/).WriteFlusher.flush(WriteFlusher.java:422)
	at [o.eclipse.jetty.io](http://o.eclipse.jetty.io/).WriteFlusher.write(WriteFlusher.java:275)
	at [o.eclipse.jetty.io](http://o.eclipse.jetty.io/).WriteFlusher.write(WriteFlusher.java:254)
	at [o.e.jetty.io](http://o.e.jetty.io/).AbstractEndPoint.write(AbstractEndPoint.java:368)
	at o.e.j.s.i.HttpConnection$SendCallback.process(HttpConnection.java:857)
	at o.e.jetty.util.IteratingCallback.processing(IteratingCallback.java:253)
	at o.e.jetty.util.IteratingCallback.iterate(IteratingCallback.java:232)
	at o.e.j.s.i.HttpConnection$HttpStreamOverHTTP1.send(HttpConnection.java:1448)
	at o.e.j.s.i.HttpChannelState$ChannelResponse.write(HttpChannelState.java:1332)
	at o.e.j.s.handler.ErrorHandler.generateAcceptableResponse(ErrorHandler.java:257)
	at o.e.j.s.handler.ErrorHandler.generateResponse(ErrorHandler.java:163)
	at o.e.j.s.handler.ErrorHandler.handle(ErrorHandler.java:118)
	at o.eclipse.jetty.server.Response.writeError(Response.java:635)
	at o.eclipse.jetty.server.Response.writeError(Response.java:550)
	at o.e.j.s.i.HttpChannelState$ChannelCallback.failed(HttpChannelState.java:1639)
	at o.e.j.s.i.HttpChannelState.lambda$onFailure$1(HttpChannelState.java:458)
	at o.e.j.u.t.ReservedThreadExecutor$ReservedThread.run(ReservedThreadExecutor.java:311)
	at o.e.j.u.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:981)
	at o.e.j.u.t.QueuedThreadPool$Runner.doRunJob(QueuedThreadPool.java:1211)
	at o.e.j.u.t.QueuedThreadPool$Runner.run(QueuedThreadPool.java:1166)
	at java.base/java.lang.Thread.run(Thread.java:840)
   gusId: a6f000000000001
   level: DEBUG
   logger: org.eclipse.jetty.server.internal.HttpChannelState
   message: ErrorWrite failed: ErrorCallback@1f32cc46
   namespace:
   thread: qtp686421688-11752
   timestamp: 1757023505758

Please help with the same
How to reproduce?
Not able to reproduce

Metadata

Metadata

Assignees

Labels

BugFor general bugs on Jetty side

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions