-
Notifications
You must be signed in to change notification settings - Fork 106
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
[gorouter] Add property to restrict header count and size #309
Comments
max_headers
max_header_size
|
@ameowlia thanks for the feedback! First of all: yes, we always want to make sure to not break any existing setups, the properties would be disabled by default and only considered when explicitly enabled. I should've provided a bit more detail in my initial issue: HAProxy has two main buffer sizes:
max_headers We want to be able to set some limit that applies to request and response headers. The main reason to add such a property is to fail in gorouter and show the failure in logs the user can access (+ the max_header_size Agreed, this covers our use-case. Adding a flag to enforce the limit on responses as well sounds good! Footnotes
|
Sounds good to me; I look forward to the PR! (Also I learned about markdown footnotes 😮.) |
Hey @MarcPaquette, thx for checking in! |
Looking into this I noticed that we are forced to do our own accounting as the request would otherwise be invisible in our logs. I've commented on golang/go#21548 as we really need a solution for this, this has become a recurring pattern for us by now (other examples include TLS handshake errors or connections which abort half-way through the headers). As we have to work with the parsed representation of the request this entire accounting is error-prone. One thing I noticed is that repeated header keys are not accounted for, so repeating Another thing which is unclear to me is whether we should distinguish between HTTP/1.1 and HTTP/2. Given that HTTP/2 is a binary protocol with framing, properly counting the bytes on the wire will be impossible as there is no way of knowing how many frames were used to transmit the headers. So our best guess is to just treat them equally and always count according to the HTTP/1.1 representation? Coming back to the original issue, what I wanted initially was to limit the amount of bytes read from the wire from the start of each request - independent of protocol etc. but without a change to the stdlib this won't be possible. Limiting the received headers from the application looks much more straight forward. Setting the limit and then exceeding it will simply result in an error which can be handled. |
Add a new property to configure the response header limit of the transport used to send request to route services and backends. Resolves: cloudfoundry/routing-release#309
We deploy gorouter behind HAProxy which limits the amount of headers and the size of each header for requests and responses. For requests towards CF this isn't much of an issue since the request is rejected with
400: Bad Request
and it never reaches the application. However, response headers are processed by the gorouter and the request shows up as200: OK
but is later rejected by HAProxy and returned as a502: Bad Gateway
to the client.To avoid this behaviour which is confusing for users, we would like to introduce two properties:
max_headers: int
to limit the amount of req/res headersmax_header_size: int
to limit the number of bytesa single header is allowed to occupythe request/response line and headers (without body) are allowed to occupyThis allows us to reject responses in gorouter and show the error message in the app logs which are visible to the user.
We can implement this feature but would like to first discuss if there are any concerns/questions. Leave a 👍 if you like this / don't see any issues with it.
The text was updated successfully, but these errors were encountered: