Summary
Capsule contains a comparison-ordering flaw in its forbidden metadata key validation. An authenticated tenant owner may bypass a configured namespace, Service, or delegated node metadata restriction when forbidden keys use capitalization patterns that are sorted differently by the validator and its binary search.
Affected context
The issue occurs in Capsule deployments that use ForbiddenListSpec.ExactMatch to restrict metadata keys. It becomes relevant when an administrator-configured forbidden list contains mixed-case keys, or other entries whose case-insensitive ordering differs from their byte-order ordering. Uniformly lowercase lists whose orderings coincide are not affected.
Exploit preconditions
- Attack surface: Capsule tenant metadata validation through Kubernetes-facing APIs
- Required access: Authenticated access as a tenant owner with permission to submit or modify relevant tenant-scoped resources
- Trigger point: Validation of metadata keys against
ForbiddenListSpec.ExactMatch - Why exploitation is possible: The forbidden list is prepared using case-insensitive ordering, while
sort.SearchStringsexpects byte-order sorting, allowing a present key to be missed by the binary search
Why this happens
The underlying bug is an inconsistent ordering assumption between list preparation and lookup. Forbidden keys are sorted case-insensitively, but the binary-search routine expects the collection to be sorted according to byte-order comparisons. When those orderings differ, the search can incorrectly report that a denied key is absent. This maps primarily to CWE-697: Incorrect Comparison, with an authorization impact related to CWE-863: Incorrect Authorization.
Potential impact
- A tenant owner may bypass selected metadata restrictions
- Namespace or Service policy boundaries could be weakened
- Delegated node metadata restrictions could be bypassed
- Network exposure could increase through improperly permitted metadata
- Workload scheduling could be influenced outside intended tenant constraints
- Cluster governance or multi-tenancy guarantees could be weakened
General mitigation guidance
Mitigation generally focuses on making collection ordering and lookup semantics consistent, or avoiding order-dependent searches for policy enforcement.
Common defensive patterns include:
- Using the same comparison function for sorting and searching
- Preferring exact-match sets or normalized-key maps for membership checks
- Normalizing metadata keys consistently before validation where Kubernetes semantics permit
- Treating policy validation as deny-by-default when lookup behavior is uncertain
- Limiting tenant permissions according to least privilege
- Reviewing existing forbidden lists for mixed-case entries and enforcing a documented normalization policy
- Applying independent admission and authorization controls for sensitive metadata
How teams detect issues like this
Organizations can look for this class of issue through:
- Static analysis rules that compare sorting comparators with binary-search comparators
- Code review checks for case normalization, locale-sensitive comparisons, and membership tests
- Unit tests covering mixed-case, duplicate, empty, and boundary-position keys
- Property-based tests verifying that every listed forbidden key is rejected
- Policy tests that submit restricted metadata through each supported resource path
- Admission or authorization monitoring for tenant resources containing keys expected to be denied
- Automated review tools that flag inconsistent comparator usage and authorization checks

