@@ -15,25 +15,33 @@ option (udpa.annotations.file_status).package_version_status = ACTIVE;
15
15
16
16
// This extension validates that HTTP request and response headers are well formed according to respective RFCs.
17
17
//
18
- // #. HTTP/1 header map validity according to `RFC 7230 section 3.2 <https://datatracker.ietf.org/doc/html/rfc7230#section-3.2>`_
19
- // #. Syntax of HTTP/1 request target URI and response status
20
- // #. HTTP/2 header map validity according to `RFC 7540 section 8.1.2 <https://datatracker.ietf.org/doc/html/rfc7540#section-8.1.2>`_
21
- // #. Syntax of HTTP/2 pseudo headers
22
- // #. HTTP/3 header map validity according to `RFC 9114 section 4.3 <https://www.rfc-editor.org/rfc/rfc9114.html>`_
23
- // #. Syntax of HTTP/3 pseudo headers
24
- // #. Syntax of Content-Length and Transfer-Encoding
25
- // #. Validation of HTTP/1 requests with both ``Content-Length`` and ``Transfer-Encoding`` headers
18
+ // The validator performs comprehensive HTTP header validation including:
19
+ //
20
+ // #. HTTP/1 header map validity according to `RFC 7230 section 3.2 <https://datatracker.ietf.org/doc/html/rfc7230#section-3.2>`_.
21
+ // #. Syntax of HTTP/1 request target URI and response status.
22
+ // #. HTTP/2 header map validity according to `RFC 7540 section 8.1.2 <https://datatracker.ietf.org/doc/html/rfc7540#section-8.1.2>`_.
23
+ // #. Syntax of HTTP/2 pseudo headers.
24
+ // #. HTTP/3 header map validity according to `RFC 9114 section 4.3 <https://www.rfc-editor.org/rfc/rfc9114.html>`_.
25
+ // #. Syntax of HTTP/3 pseudo headers.
26
+ // #. Syntax of Content-Length and Transfer-Encoding.
27
+ // #. Validation of HTTP/1 requests with both ``Content-Length`` and ``Transfer-Encoding`` headers.
26
28
// #. Normalization of the URI path according to `Normalization and Comparison <https://datatracker.ietf.org/doc/html/rfc3986#section-6>`_
27
- // without `case normalization <https://datatracker.ietf.org/doc/html/rfc3986#section-6.2.2.1>`_
29
+ // without `case normalization <https://datatracker.ietf.org/doc/html/rfc3986#section-6.2.2.1>`_.
30
+ //
31
+ // This validator ensures that HTTP traffic processed by Envoy conforms to established
32
+ // standards and helps prevent issues caused by malformed headers or invalid HTTP syntax.
28
33
//
29
34
// [#comment:TODO(yanavlasov): Put #extension: envoy.http.header_validators.envoy_default after it is not hidden any more]
30
35
// [#next-free-field: 6]
31
36
message HeaderValidatorConfig {
32
37
// Action to take when Envoy receives client request with header names containing underscore
33
38
// characters.
34
- // Underscore character is allowed in header names by the RFC-7230 and this behavior is implemented
35
- // as a security measure due to systems that treat '_' and '-' as interchangeable. Envoy by default allows client request headers with underscore
36
- // characters.
39
+ //
40
+ // Underscore character is allowed in header names by RFC-7230, and this behavior is implemented
41
+ // as a security measure due to systems that treat ``_`` and ``-`` as interchangeable. Envoy by
42
+ // default allows client request headers with underscore characters.
43
+ //
44
+ // This setting provides control over how to handle such headers for security and compatibility reasons.
37
45
enum HeadersWithUnderscoresAction {
38
46
// Allow headers with underscores. This is the default behavior.
39
47
ALLOW = 0 ;
@@ -51,102 +59,170 @@ message HeaderValidatorConfig {
51
59
DROP_HEADER = 2 ;
52
60
}
53
61
62
+ // Configuration options for URI path normalization and transformation.
63
+ //
64
+ // These options control how Envoy processes and normalizes incoming request URI paths
65
+ // to ensure consistent behavior and security. Path normalization helps prevent
66
+ // path traversal attacks and ensures that equivalent paths are handled consistently.
54
67
message UriPathNormalizationOptions {
55
68
// Determines the action for requests that contain ``%2F``, ``%2f``, ``%5C`` or ``%5c`` sequences in the URI path.
56
69
// This operation occurs before URL normalization and the merge slashes transformations if they were enabled.
70
+ //
71
+ // Escaped slash sequences in URLs can be used for path confusion attacks, so proper handling
72
+ // is important for security.
57
73
enum PathWithEscapedSlashesAction {
58
74
// Default behavior specific to implementation (i.e. Envoy) of this configuration option.
59
75
// Envoy, by default, takes the ``KEEP_UNCHANGED`` action.
60
- // NOTE: the implementation may change the default behavior at-will.
76
+ //
77
+ // .. note::
78
+ //
79
+ // The implementation may change the default behavior at-will.
80
+ //
61
81
IMPLEMENTATION_SPECIFIC_DEFAULT = 0 ;
62
82
63
- // Keep escaped slashes.
83
+ // Keep escaped slashes unchanged in the URI path.
84
+ // This preserves the original request path without any modifications to escaped sequences.
64
85
KEEP_UNCHANGED = 1 ;
65
86
66
87
// Reject client request with the 400 status. gRPC requests will be rejected with the ``INTERNAL`` (13) error code.
67
- // The ``http#.downstream_rq_failed_path_normalization`` counter is incremented for each rejected request.
88
+ // The :ref:`httpN.downstream_rq_failed_path_normalization <config_http_conn_man_stats_per_codec>` counter is incremented for each rejected request.
89
+ //
90
+ // This is the safest option when security is a primary concern, as it prevents any potential
91
+ // path confusion attacks by rejecting requests with escaped slashes entirely.
68
92
REJECT_REQUEST = 2 ;
69
93
70
94
// Unescape ``%2F`` and ``%5C`` sequences and redirect the request to the new path if these sequences were present.
71
95
// The redirect occurs after path normalization and merge slashes transformations if they were configured.
72
- // NOTE: gRPC requests will be rejected with the ``INTERNAL`` (13) error code.
73
- // This option minimizes possibility of path confusion exploits by forcing request with unescaped slashes to
74
- // traverse all parties: downstream client, intermediate proxies, Envoy and upstream server.
75
- // The ``http#.downstream_rq_redirected_with_normalized_path`` counter is incremented for each
96
+ //
97
+ // .. note::
98
+ //
99
+ // gRPC requests will be rejected with the ``INTERNAL`` (13) error code.
100
+ // This option minimizes possibility of path confusion exploits by forcing request with unescaped slashes to
101
+ // traverse all parties: downstream client, intermediate proxies, Envoy and upstream server.
102
+ //
103
+ // The :ref:`httpN.downstream_rq_redirected_with_normalized_path <config_http_conn_man_stats_per_codec>` counter is incremented for each
76
104
// redirected request.
77
105
UNESCAPE_AND_REDIRECT = 3 ;
78
106
79
107
// Unescape ``%2F`` and ``%5C`` sequences.
80
- // Note: this option should not be enabled if intermediaries perform path based access control as
81
- // it may lead to path confusion vulnerabilities.
108
+ //
109
+ // .. attention::
110
+ //
111
+ // This option should not be enabled if intermediaries perform path based access control as
112
+ // it may lead to path confusion vulnerabilities.
113
+ //
82
114
UNESCAPE_AND_FORWARD = 4 ;
83
115
}
84
116
85
117
// Should paths be normalized according to RFC 3986?
118
+ //
86
119
// This operation overwrites the original request URI path and the new path is used for processing of
87
120
// the request by HTTP filters and proxied to the upstream service.
88
121
// Envoy will respond with 400 to requests with malformed paths that fail path normalization.
89
122
// The default behavior is to normalize the path.
123
+ //
90
124
// This value may be overridden by the runtime variable
91
125
// :ref:`http_connection_manager.normalize_path<config_http_conn_man_runtime_normalize_path>`.
92
126
// See `Normalization and Comparison <https://datatracker.ietf.org/doc/html/rfc3986#section-6>`_
93
127
// for details of normalization.
94
- // Note that Envoy does not perform
95
- // `case normalization <https://datatracker.ietf.org/doc/html/rfc3986#section-6.2.2.1>`_
96
- // URI path normalization can be applied to a portion of requests by setting the
97
- // ``envoy_default_header_validator.path_normalization`` runtime value.
128
+ //
129
+ // .. note::
130
+ //
131
+ // Envoy does not perform
132
+ // `case normalization <https://datatracker.ietf.org/doc/html/rfc3986#section-6.2.2.1>`_.
133
+ // URI path normalization can be applied to a portion of requests by setting the
134
+ // ``envoy_default_header_validator.path_normalization`` runtime value.
135
+ //
98
136
bool skip_path_normalization = 1 ;
99
137
100
138
// Determines if adjacent slashes in the path are merged into one.
139
+ //
101
140
// This operation overwrites the original request URI path and the new path is used for processing of
102
141
// the request by HTTP filters and proxied to the upstream service.
103
- // Setting this option to true will cause incoming requests with path ``//dir///file`` to not match against
104
- // route with ``prefix`` match set to ``/dir``. Defaults to ``false``. Note that slash merging is not part of
105
- // `HTTP spec <https://datatracker.ietf.org/doc/html/rfc3986>`_ and is provided for convenience.
106
- // Merging of slashes in URI path can be applied to a portion of requests by setting the
107
- // ``envoy_default_header_validator.merge_slashes`` runtime value.
142
+ // Setting this option to ``true`` will cause incoming requests with path ``//dir///file`` to not match against
143
+ // route with ``prefix`` match set to ``/dir``. Defaults to ``false``.
144
+ //
145
+ // .. note::
146
+ //
147
+ // Slash merging is not part of the
148
+ // `HTTP spec <https://datatracker.ietf.org/doc/html/rfc3986>`_ and is provided for convenience.
149
+ // Merging of slashes in URI path can be applied to a portion of requests by setting the
150
+ // ``envoy_default_header_validator.merge_slashes`` runtime value.
151
+ //
108
152
bool skip_merging_slashes = 2 ;
109
153
110
154
// The action to take when request URL path contains escaped slash sequences (``%2F``, ``%2f``, ``%5C`` and ``%5c``).
155
+ //
111
156
// This operation may overwrite the original request URI path and the new path is used for processing of
112
157
// the request by HTTP filters and proxied to the upstream service.
158
+ //
159
+ // The handling of escaped slashes is important for security as these sequences can be used
160
+ // in path confusion attacks to bypass access controls.
113
161
PathWithEscapedSlashesAction path_with_escaped_slashes_action = 3
114
162
[(validate.rules ).enum = {defined_only : true}];
115
163
}
116
164
165
+ // HTTP/1 protocol specific options for header validation.
166
+ //
167
+ // These options control how Envoy handles HTTP/1 specific behaviors and edge cases
168
+ // that may not apply to HTTP/2 or HTTP/3 protocols.
117
169
message Http1ProtocolOptions {
118
170
// Allows Envoy to process HTTP/1 requests/responses with both ``Content-Length`` and ``Transfer-Encoding``
119
171
// headers set. By default such messages are rejected, but if option is enabled - Envoy will
120
172
// remove the ``Content-Length`` header and process the message.
173
+ //
121
174
// See `RFC7230, sec. 3.3.3 <https://datatracker.ietf.org/doc/html/rfc7230#section-3.3.3>`_ for details.
122
175
//
123
176
// .. attention::
177
+ //
124
178
// Enabling this option might lead to request smuggling vulnerabilities, especially if traffic
125
179
// is proxied via multiple layers of proxies.
180
+ //
126
181
bool allow_chunked_length = 1 ;
127
182
}
128
183
184
+ // HTTP/1 protocol specific options.
185
+ // These settings control HTTP/1 specific validation behaviors.
129
186
Http1ProtocolOptions http1_protocol_options = 1 ;
130
187
131
188
// The URI path normalization options.
189
+ //
132
190
// By default Envoy normalizes URI path using the default values of the :ref:`UriPathNormalizationOptions
133
191
// <envoy_v3_api_msg_extensions.http.header_validators.envoy_default.v3.HeaderValidatorConfig.UriPathNormalizationOptions>`.
134
192
// URI path transformations specified by the ``uri_path_normalization_options`` configuration can be applied to a portion
135
193
// of requests by setting the ``envoy_default_header_validator.uri_path_transformations`` runtime value.
136
- // Caution: disabling path normalization may lead to path confusion vulnerabilities in access control or incorrect service
137
- // selection.
194
+ //
195
+ // .. attention::
196
+ //
197
+ // Disabling path normalization may lead to path confusion vulnerabilities in access control or incorrect service
198
+ // selection.
199
+ //
138
200
UriPathNormalizationOptions uri_path_normalization_options = 2 ;
139
201
140
- // Restrict HTTP methods to these defined in the `RFC 7231 section 4.1 <https://datatracker.ietf.org/doc/html/rfc7231#section-4.1>`_
202
+ // Restrict HTTP methods to these defined in the `RFC 7231 section 4.1 <https://datatracker.ietf.org/doc/html/rfc7231#section-4.1>`_.
203
+ //
141
204
// Envoy will respond with 400 to requests with disallowed methods.
142
205
// By default methods with arbitrary names are accepted.
206
+ //
207
+ // This setting helps enforce HTTP compliance and can prevent attacks that rely on
208
+ // non-standard HTTP methods.
143
209
bool restrict_http_methods = 3 ;
144
210
145
211
// Action to take when a client request with a header name containing underscore characters is received.
146
- // If this setting is not specified, the value defaults to ALLOW.
212
+ //
213
+ // If this setting is not specified, the value defaults to ``ALLOW``.
214
+ //
215
+ // This setting provides security control over headers with underscores, which can be a source
216
+ // of security issues when different systems interpret underscores and hyphens differently.
147
217
HeadersWithUnderscoresAction headers_with_underscores_action = 4 ;
148
218
149
219
// Allow requests with fragment in URL path and strip the fragment before request processing.
150
- // By default Envoy rejects requests with fragment in URL path.
220
+ //
221
+ // By default Envoy rejects requests with fragment in URL path. When this option is enabled,
222
+ // the fragment portion (everything after ``#``) will be removed from the path before
223
+ // further processing.
224
+ //
225
+ // Fragments are typically used by client-side applications and should not normally
226
+ // be sent to the server, so stripping them can help normalize requests.
151
227
bool strip_fragment_from_path = 5 ;
152
228
}
0 commit comments