GeezerVison is showing github.com — Prevent leaking a ByteBuf during http2->http1 conversion by jguerra · Pull Request #18254 · netty/netty
Conversation
jguerra
commented
Nov 3, 2026
•
edited
Loading
Uh oh!
There was an error while loading. Please reload this page.
Motivation:
Http2StreamFrameToHttpObjectCodec can leak a ByteBuf when converting http2 headers to a FullHttpRequest. For example, if the http2 headers are missing a :path or :method contains an illegal character, HttpConversionUtil.toFullHttpRequest will throw an exception without releasing the content passed in
Modification:
I moved the validation logic in HttpConversionUtil.toFullHttpRequest() and HttpConversionUtil.toFullHttpResponse() into the existing try/catch, and modified the release to operate on the ByteBuf instead of the request/response msg. As a result of this, the exception thrown for different types of validation errors changes. Previously, a missing :path header would throw a NPE, while an illegal method would throw an IllegalArgumentException. With my changes these errors are now wrapped in a Http2Exception. Because of this, I also modified toHttpRequest() and toHttpResponse() to have consistent exception types, even though they have no risk of leaking memory.
Result:
Http2StreamFrameToHttpObjectCodec no longer leaks a ByteBuf on invalid http2 headers
- Validation errors during http2 -> http1 conversion are now wrapped in a
Http2Exception
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
gavinbunney reacted with thumbs up emoji
|
@normanmaurer can you consider this one for the next release? 🙏 In the proxy I work on get a fair amount of spurious leak reports due to this issue
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
testlens-app
Bot
commented
Nov 26, 2026
•
edited
Loading
Uh oh!
There was an error while loading. Please reload this page.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
|
addHttp2ToHttpHeaders(streamId, http2Headers, msg, false);
|
|
|
} catch (Http2Exception e) {
|
|
|
msg.release();
|
|
|
content.release();
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is not correct... I think it would be more correct to release the msg if its not null and only if its null release content. While it makes no difference in practice I think it's still more correct and future proof. Same goes for the other places.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Assignees
No one assigned
Development
Successfully merging this pull request may close these issues.
Uh oh!
There was an error while loading. Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.