Add maxHeadersCount support for http(s)2 serverΒ #32388
Copy link
Copy link
Closed
Labels
feature requestIssues requesting new Node.js features.Issues requesting new Node.js features.http2Issues and PRs related to the http2 subsystem.Issues and PRs related to the http2 subsystem.
Description
Is your feature request related to a problem? Please describe.
In http(s)1, user can limit server.maxHeadersCount for server, to avoid malicious request (like hash collision attack), because normal headers wont be more than 20 in fact.
But in http(s)2, user has no chance to prevent parse that, even if user check request.rawHeaders.length/2>2000 && response.writeHead(400), the request.headers already been parsed.
Describe the solution you'd like
Add server.maxHeadersCount, just like http(s)1 did.
Describe alternatives you've considered
Reacted by Alex Yang, Max Nanasy and Abdul Rahman Khankan
Metadata
Metadata
Assignees
Labels
feature requestIssues requesting new Node.js features.Issues requesting new Node.js features.http2Issues and PRs related to the http2 subsystem.Issues and PRs related to the http2 subsystem.
Activity
addaleax commentedon Mar 20, 2020
Sounds good to me β
maxHeaderSizecould be added along with that. πLongTengDao commentedon Mar 20, 2020
I found
maxHeaderListPairsin docs accidentally. Are they same?addaleax commentedon Mar 20, 2020
@LongTengDao Yeah, actually, thatβs the same thing. Itβs really unfortunate how the naming mismatches β I guess that means adding an alias makes sense here?
LongTengDao commentedon Mar 20, 2020
I didn't found that, not only because the name, but also the way to set... one is property of instance, one is in creating options.
I have no idea. Maybe deprecate
server.maxHeadersCountin http1 tomaxHeaderListPairsalso works?By the way, via reading the source, I found the effects of
server.maxHeadersCountseems to prevent excessiverequest.headersassigning:and prevent excessive
request.rawHeaderspushing which depends on if the headers are recieved in two times or not:Does
maxHeaderListPairsdo exact same? I couldn't found more useful infomation by search in source.himself65 commentedon Mar 24, 2020
@LongTengDao You should read this PR #16676. And use git blame instead of global text search
himself65 commentedon Mar 25, 2020
I read the source code these days.
And I found that
httpusemaxHeadersCount, buthttp2usemaxHeaderListPairs, which they use the different C++ library and implement.Unify them not easy work. π
himself65 commentedon Mar 26, 2020
I've done this issue which adds aliases for
http1/2namedmaxHeadersCountandmaxHeaderListPairs,but I'm doubting that if we really need this kind of thing.
Adding the aliases will add the complexity of the code, that we have two option mange the one thing. Actually, I disapprove of this feature.
π€
LongTengDao commentedon Mar 27, 2020
Maybe just add explain in docs will resolve this (if we can't remove one of them, and just reserve anothor)?
himself65 commentedon Mar 27, 2020
add doc is a good idea
doc: specify maxHeaderCount alias for maxHeaderListPairs
doc: specify maxHeaderCount alias for maxHeaderListPairs
doc: specify maxHeaderCount alias for maxHeaderListPairs
doc: specify maxHeaderCount alias for maxHeaderListPairs
doc: specify maxHeaderCount alias for maxHeaderListPairs
doc: specify maxHeaderCount alias for maxHeaderListPairs
doc: specify maxHeaderCount alias for maxHeaderListPairs