-
Notifications
You must be signed in to change notification settings - Fork 5k
Description
Per #2334, the idea is to allow metadata matches (used to select subsets via the subset load balancer) to be computed from request data. Specifically, the intent is to match request header values against a regular expression and allow matched groups to be used as metadata values.
Configuration
One question is how to encode this configuration. Two proposals have been made.
- Encode the regexes and metadata mappings in a structure parallel to the existing
metadata_match
field ofRouteAction
. - Use the regexes already encoded in the
regex
field ofRouteMatch
and introduce an additional field to allow mapping matched groups to metadata.
Option 1 allows headers to be optionally matched and converted into match criteria for the purposes of load balancing. Several optional headers could be defined and the resulting match criteria (if any) applied to routing. This option may cause the same header to be matched against multiple regular expressions (one to match the route, and one to extract metadata values).
Option 2 requires producing a route for each valid combination of headers. N optional, independent headers that produce match criteria would require 2^N routes. For a given route regexes are only matched once.
In either case, care will have to be taken to make sure the match criteria delivered to the subset load balancer are correctly sorted.
Security Considerations
My analysis is that any configuration using dynamically generated match criteria for the subset load balancer can be written using static match criteria, given a sufficient number of routes. There may be need to limit the length of header values or extract match criteria to avoid large memory allocations in the request path (existing header limits may be sufficient). Allowing arbitrary matches might allow an attacker to craft special requests to probe for metadata matches that were not meant to be exposed (e.g. internal-use versions, etc.)