# Non-injective route key collisions

Delimiter-joined namespace and name keys that can collide, letting one tenant overwrite or hijack another's route

_Area: Cloud and container security. Seen in 2 disclosed reports; latest 2026-08-06. Updated 2026-10-25._

## How it works
A controller needs a stable key for each object, so it joins user-controlled fields (namespace, name, gateway, rule index) with a delimiter like `-` and uses that string as a map key, cache key, or file path. The join is not injective: when the fields themselves contain the delimiter, two different tuples produce the same string. `team/a-app` and `team-a/app` both become `team-a-app`. A later write silently overwrites the earlier entry, so one tenant's route, file, or backend entry replaces another's. The broken assumption is that the delimiter cannot appear inside the components, or that normalization preserves component boundaries.

## Where it shows up
- `fmt.Sprintf("%s-%s", ns, name)` or similar joins used as map keys, cache keys, or filenames.
- A `Normalize`/slug step that collapses non-alphanumerics to `-` after joining, erasing boundaries.
- `maps.Copy` or plain map assignment that overwrites on collision without checking.
- Filesystem paths like `{namespace}-{ingress}.passwd` derived from Kubernetes names.
- Shared controllers (ingress, LoadBalancer) trusting namespace-scoped objects such as EndpointSlice/Endpoint for routing targets.

## How to review
Check the exact property: the key construction must be injective over the tuple. Either escape/length-prefix each component, use a structured key (nested maps, tuple struct), or reject names containing the delimiter. Verify collisions are detected and rejected, not silently merged. For shared controllers, confirm that a tenant cannot write an object that redirects traffic outside its own namespace. Trace every place a joined string becomes a key, path, or route target.

## Variants seen
- Hyphen-joined route key with normalization collapsing boundaries; later Route hijacks victim traffic [E1](https://bugbountylibrary.com/r/ghsa%3AGHSA-fgjj-px3w-67xx.md).
- htpasswd filename `{namespace}-{ingress}.passwd`; crafted split overwrites another ingress's auth file, bypassing HTTP auth [E2](https://bugbountylibrary.com/r/h1%3A778803.md).
- Tenant-editable EndpointSlice trusted by shared ingress/LoadBalancer, redirecting traffic to other tenants' pods [E3](https://bugbountylibrary.com/r/blog%3Asecuritylabs-datadoghq-com-articles-unpatchable-kubernetes-vulnerabilities-cve-2021-25740.md).

## Impact and severity
Cross-namespace traffic hijacking, authentication bypass, and cross-tenant redirection. Severity is high in multi-tenant clusters where a shared controller or load balancer reaches all namespaces; silent overwrite makes it hard to notice.

## Why fixes fail
Normalization that collapses characters does not restore injectivity; it widens the collision set. Fixes must change the key construction, not just the delimiter.

## Evidence
- E1: https://bugbountylibrary.com/r/ghsa%3AGHSA-fgjj-px3w-67xx.md
- E2: https://bugbountylibrary.com/r/h1%3A778803.md
- E3: https://bugbountylibrary.com/r/blog%3Asecuritylabs-datadoghq-com-articles-unpatchable-kubernetes-vulnerabilities-cve-2021-25740.md
