Parser only stores standard trailer fields#3042
Conversation
efcac5c to
3a06820
Compare
|
Is there a linked issue for this change? Specifically, I am concerned this will break custom trailer headers for existing users of Beast, see e.g. https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Headers/Trailer. As you can see it's not a feature browsers typically support, but we're typically not writing/dealing with browsers here, so the feature might be used (for things like debugging, telemetry, custom digests). |
This is actually a security concern and stems from the fact that we are storing trailer fields and initial fields in the same container. As a result, it is possible for a chunked message to add arbitrary fields to a message at the end.
For more advanced use cases, users can create their own parser class derived from By the way, this is a draft PR, so we can consider all the alternatives and decide. |
3a06820 to
64717a5
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #3042 +/- ##
========================================
Coverage 93.17% 93.18%
========================================
Files 176 176
Lines 13689 13690 +1
========================================
+ Hits 12755 12757 +2
+ Misses 934 933 -1
Continue to review full report in Codecov by Sentry.
🚀 New features to boost your workflow:
|
|
Another option could be to check if a trailer field is listed in the |
I think it's how the RFC is intended, though. Also, it would allow you to check that disallowed headers are not named, or no trailing headers would overwrite existing headers. That way, it would already safer by default. I can see room for a flag "allow non-standard trailers". I'm not sure how feasible it would be for a derived parser to override the on-trailer-header handler, but that idea could work. |
The problem is there isn’t a concrete list of disallowed headers, that’s why I went with a whitelist instead.
Yes, this would make it much safer, although it would still allow an attacker to append arbitrary fields (e.g.
This depends on how often trailer headers are used in the wild, and if they are, how many of these usages don’t fall into the whitelist we already have. Considering trailer fields are disallowed in browsers (except So, my attempt is to avoid complicating the current interface unless we have evidence that the feature is used in the wild. The closest thing I found was gRPC’s |
Honoring the |
Only iff it were named in a
Again, my concern is the opposite. Currently, users of the library can rely on this functionality. It should be reasonably possible to achieve the same result with the changes. Again:
If it's trivial, a 16-word sketch in the release notes could do |
bbd3cdf to
720beeb
Compare
|
@sehe, the behavior has changed as follows:
Regardless of the settings, any trailer header not listed in the |
720beeb to
e7dbd3d
Compare
|
An automated preview of the documentation is available at https://3042.beast.prtest.cppalliance.org/libs/beast/doc/html/index.html If more commits are pushed to the pull request, the docs will rebuild at the same URL. 2025-10-16 12:04:57 UTC |
e7dbd3d to
5583b90
Compare
Awesome. That looks like it covers all purposes nicely. My only review comment would be that the comment I'm replying to does a FAR better job documenting the behavior than the doxygen. Notably,
|
I first went with |
1c27105 to
c27261f
Compare
c27261f to
be514fe
Compare
be514fe to
a92c5ce
Compare
Replace boost `http::field::http2_settings` with hand-coded "HTTP2-Settings". Non-standard header fields were removed in 1.90, http2_settings included. [boost_pr]: boostorg/beast#3042
Replace boost `http::field::http2_settings` with hand-coded "HTTP2-Settings". Non-standard header fields were removed in 1.90, http2_settings included. [boost_pr]: boostorg/beast#3042
No description provided.