-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
HPAX.resize/2
does not satisfy the requirements of HTTP/2 SETTINGS_MAX_HEADER_LIST_SIZE
settings updates
#18
Comments
HPAX.resize/2
is not the way to handle HTTP/2 SETTINGS_MAX_HEADER_LIST_SIZE
settings updatesHPAX.resize/2
does not satisfy the requirements of HTTP/2 SETTINGS_MAX_HEADER_LIST_SIZE
settings updates
@mtrudel thanks for the heads up! |
I'm most of the way through this work and I've come to the realization that I think we need something like a
HPAX currently checks the size of such updates against So what we actually need in Table is:
|
As identified at mtrudel/bandit#392, calling
HPAX.resize/2
does not correctly perform the steps needed to handle HTTP/2 settings updates that change theSETTINGS_MAX_HEADER_LIST_SIZE
value.What the RFCS say
RFC9113§4.3.1 describes the process1 of how changes to
SETTINGS_MAX_HEADER_LIST_SIZE
are undertaken in terms of the decoder and encoder ends of an HPACK context:How HPAX should be used (and what it should be doing)
On the encoder, application-level calls to
HPAX.resize/2
should be made when the encoder receives a settings frame from the decoder, with the application passing a value no larger than the value specified in the settings frame.On the decoder, application-level calls to
HPAX.resize/2
should be made when the decoder receives a settings ACK (NOT when the settings frame is sent), with the application passing in the exact value from the settings frame that was acknowledged, possibly evicting records as needed.The decoder should process dynamic table size update messages by first ensuring that the message is not increasing the maximum size of the table. It should then be setting the table's max size to the value indicated, possibly evicting records as needed.
Where HPAX currently falls short
HPAX's current implementation is insufficient in the following two ways:
HPAX.Table.resize/2
does not update the max table size, it only evicts entries to decrease the size of the contents of the table. We should be updatingmax_table_size
as part of the resize behaviour.max_table_size
issue above, the current behaviour ofHPAX.resize/2
is insufficient on the encoder side. If the max size has decreased, we must send a dynamic table size update to the decoder.There are four existing calls to
HPAX.resize/2
across all of HPAX's hex dependents:Proposed Solution
Based on the above, I propose that we should:
Move the existing
HPAX.Table.resize/2
function to a privateHPAX.Table.evict_to_max_size/2
since it is used in table addition (its current behaviour is correct for this purpose).Create a new
HPAX.Table.resize/2
implementation that callsHPAX.Table.evict_to_max_size/2
and also sets the value ofmax_table_size
as indicated. This will correctly implement the behaviour required when it is called on the decoder (both explicitly by the application upon receipt of settings frame asks, and also as part of receiving a dynamic table size update).Add logic to
HPAX.Table.resize/2
to set a flag on the table whenever the table max size is adjusted downward. This flag should be checked when encoding, and if set the encoding should have a dynamic table size update prepended (and the flag subsequently cleared). There is no need to discriminate between encoder and decoder users here, since decoders will never be encoding (and so the flag is vestigial in this case).I'm happy to undertake this work, but given its subtlety I think it's good to have multiple people think through it and ensure it's a sensible solution.
Footnotes
Of note, this process was not specified as part of the original RFC 7540; details were only added in RFC 9113 (see Appendix B). ↩
The text was updated successfully, but these errors were encountered: