Repository navigation
Commit 4a0a639
authored
geoip: remove configured geolocation headers from the request before the lookup (#48363)
Commit Message: geoip: remove configured geolocation headers from the
request before the lookup
Additional Description:
The HTTP geoip filter only wrote a geolocation header when the provider
had a value for it, and never removed one. A header the client sent
therefore reached the upstream unchanged whenever the lookup produced
nothing for it: an address absent from the database, a lookup error, a
field the database lacks for that address, or a request whose lookup was
skipped because the downstream address was not an IP address (the skip
path from #47481). The upstream, or an RBAC/ext_authz/Lua step later in
the chain, cannot tell such a header from one the filter set, although
`geoip_filter.rst` and the `geo_headers_to_add` comment say a configured
header present in the incoming request is overridden.
This change:
- adds `Geolocation::Driver::geoHeaderNames()`, additive with an empty
default, so providers that do not override it keep compiling and keep
their behavior;
- has the maxmind provider return its configured output keys
(`GeoipProviderConfig::fieldKeyNames()`), for both `geo_field_keys` and
the deprecated `geo_headers_to_add` form including the `is_anon`
fallback;
- removes those headers at the start of `GeoipFilter::decodeHeaders`,
before the address is resolved and before any path that returns without
a lookup, so a configured header is present after the filter only if the
lookup populated it. Removal rather than overwrite, because the lookup
sets no header it has no value for.
Same shape as #46586 for jwt_authn. The filter and the maxmind provider
carry `security_posture: unknown`
(`requires_trusted_downstream_and_upstream` per EXTENSION_POLICY.md), so
this is a hardening change filed publicly.
Risk Level: Low. Behavior change for a deployment that relied on
client-supplied geolocation headers passing through on the no-data
paths; reversible with the runtime guard.
Testing: Unit tests for the filter (client header removed when the
lookup has no value for it, removed on the skipped-lookup path, kept
with the guard off) and for the maxmind provider (configured keys
reported for `geo_field_keys` and for the deprecated
`geo_headers_to_add` with `is_anon`). Integration tests against the
maxmind test databases: client headers removed for an address with no
data, replaced rather than duplicated for an address with data
(216.160.83.56 has city/ASN data and is absent from the anonymous-IP
test database, so the client's `x-geo-anon-vpn` is removed while
`x-geo-country` becomes `US`).
Docs Changes:
`docs/root/configuration/http/http_filters/geoip_filter.rst` describes
the removal and the runtime guard.
Release Notes:
`changelogs/current/behavior_changes/geoip__sanitize-geo-headers.rst`.
Platform Specific Features: n/a
Runtime guard: `envoy.reloadable_features.geoip_sanitize_geo_headers`
(default true).
Fixes #48362
Generative AI: an AI assistant was used in preparing this change; I have
reviewed it and will handle review comments myself.
this closes #48362
---------
Signed-off-by: Layau Eulizier Jr <[email protected]>1 parent 09f784d commit 4a0a639
15 files changed
Lines changed: 267 additions & 2 deletions
File tree
- changelogs/current/behavior_changes
- docs/root/configuration/http/http_filters
- envoy/geoip
- source
- common/runtime
- extensions
- filters/http/geoip
- geoip_providers/maxmind
- test
- extensions
- filters/http/geoip
- geoip_providers/maxmind
- mocks/geoip
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
8 | | - | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
9 | 13 | | |
10 | 14 | | |
11 | 15 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
| 22 | + | |
22 | 23 | | |
23 | 24 | | |
24 | 25 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
| 4 | + | |
4 | 5 | | |
5 | 6 | | |
6 | 7 | | |
7 | 8 | | |
8 | 9 | | |
| 10 | + | |
9 | 11 | | |
10 | 12 | | |
11 | 13 | | |
| |||
40 | 42 | | |
41 | 43 | | |
42 | 44 | | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
43 | 56 | | |
44 | 57 | | |
45 | 58 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
96 | 96 | | |
97 | 97 | | |
98 | 98 | | |
| 99 | + | |
99 | 100 | | |
100 | 101 | | |
101 | 102 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
| 28 | + | |
28 | 29 | | |
29 | 30 | | |
30 | 31 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| 7 | + | |
7 | 8 | | |
8 | 9 | | |
9 | 10 | | |
| |||
43 | 44 | | |
44 | 45 | | |
45 | 46 | | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
46 | 58 | | |
47 | 59 | | |
48 | 60 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
46 | 46 | | |
47 | 47 | | |
48 | 48 | | |
| 49 | + | |
49 | 50 | | |
50 | 51 | | |
51 | 52 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
189 | 189 | | |
190 | 190 | | |
191 | 191 | | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
192 | 195 | | |
193 | 196 | | |
194 | 197 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
| 4 | + | |
4 | 5 | | |
5 | 6 | | |
6 | 7 | | |
7 | 8 | | |
| 9 | + | |
8 | 10 | | |
9 | 11 | | |
10 | 12 | | |
| |||
58 | 60 | | |
59 | 61 | | |
60 | 62 | | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
61 | 67 | | |
62 | 68 | | |
63 | 69 | | |
| |||
78 | 84 | | |
79 | 85 | | |
80 | 86 | | |
| 87 | + | |
| 88 | + | |
81 | 89 | | |
82 | 90 | | |
83 | 91 | | |
| |||
172 | 180 | | |
173 | 181 | | |
174 | 182 | | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
175 | 186 | | |
176 | 187 | | |
177 | 188 | | |
| |||
0 commit comments