Skip to content

RDS provider reuse keys on a hash of the whole Rds message: any config_source byte change silently doubles subscriptions #852

Closed

Description

@bpalermo

⚠️ CORRECTED 2026-09-20 — both premises below are WRONG at the pinned Envoy. Read this box before the original text, which is kept only for history. Fixed by PR #857.

1. initial_fetch_timeout is EXEMPT from the RDS reuse key, not "the first field released into it" — that framing was exactly backwards. source/common/rds/route_config_provider_manager.h:47-54 releases it out of the message, hashes, then restores it. Two listeners differing only there do share a provider, so #839's field is the one addition that could never have split anything. Unconditional since d9bda64c84 (envoy#40660). RDS-only: scoped RDS, ECDS and ODCDS do hash their timeout in.

2. A map-typed field cannot split a provider. MessageUtil::hash → DeterministicProtoHash::hash, a reflection walk rather than a serialisation, and reflectionHashMapField folds map entries with addition — deliberately. Maps are hash-neutral at Envoy. They remain a go-control-plane-side snapshot-version hazard (#135's actual mechanism), currently closed by the Deterministic marshals.

The real hazard is a repeated non-map field built by ranging a Go map (ConfigSource.authorities; api_config_source's grpc_services / initial_metadata / config_validators), or a genuine semantic divergence between call sites. Envoy's key is a value hash, so the "differs by a single byte" framing is wrong — pure serialisation skew cannot split anything.

The blast radius was also wrong. On aether there would be zero extra subscriptions on the wire: the chart uses api_type: DELTA_GRPC, and WatchMap::findAdditions only reports a name whose watch_interest_ had no entry, so a duplicate watch never reaches the wire. And rather than "two stats scopes", where the stat prefixes match (aether's out_http/cap_http use constant HCM prefixes) the allocator dedupes by StatName and one series reads DOUBLE — config_reload/update_success/update_attempt +2 per push, while version/update_time are set() and stay honest.

Costs the original text missed, all real: /config_dump lists the route config twice — the unambiguous signal, independent of any stat-prefix collision — plus two parsed route tables per worker thread, a second parse/build per push, and independent warming with each provider burning its own initial_fetch_timeout.

What survives unchanged: aether is safe today, and "no NACK, no warning, valid config, healthy proxy" was right.


Found while settling #844. aether is safe today; this is a trap for the next person who touches an xDS config_source.

Envoy's RouteConfigProviderManagerImpl keys provider reuse on MessageUtil::hash() of the entire Rds message — not on the route-config name. So two listeners that mean the same route config but whose config_source differs by a single byte get two subscriptions and two stats scopes, with no NACK and no warning. The config is valid; it is just silently doubled.

initial_fetch_timeout (added by #839) is only the first field released into that hash. Any future addition to the egress config_source — a rate limit, a different ads spelling, a per-call option — has the same property.

Why aether is safe now

XDSConfigSourceADSWithInitialFetch returns a constant struct literal with no map fields, so every caller produces byte-identical bytes. The risk is a future variant built conditionally, or one that acquires a map-typed field.

Why this is a familiar class

It is the same determinism hazard as #135, where transport_socket_matches ordering came from map iteration and made every snapshot hash as changed, causing a full CDS replace on every push. Proto map fields have no stable serialisation order, so a map anywhere inside a message that gets hashed is a latent instability. The lesson recorded then — "audit future repeated fields built from maps" — extends to anything feeding MessageUtil::hash().

Suggested

A comment at XDSConfigSourceADSWithInitialFetch recording that its output is hashed by Envoy for provider reuse, so it must stay a deterministic constant and must never gain a map-typed field. Optionally a test asserting two independently-constructed values serialise identically.

How it would present

Not as an error. Two stats scopes for one route config (http.<prefix>.rds.out_http.* appearing twice under different scopes), two subscriptions on the wire, and doubled RDS traffic — all with a valid config and a healthy proxy. Worth knowing the signature, because nothing fails.

Line numbers in #844's trace come from a checkout 211 commits ahead of the pin 13144fb; the load-bearing behaviour was re-verified at the pin, but the exact lines may drift.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions