Skip to content

Prevent cross-cluster LB hijack via duplicate do-loadbalancer-name - #917

Open
lazydiv wants to merge 1 commit into
digitalocean:masterfrom
lazydiv:fix/prevent-cross-cluster-lb-hijack
Open

Prevent cross-cluster LB hijack via duplicate do-loadbalancer-name#917
lazydiv wants to merge 1 commit into
digitalocean:masterfrom
lazydiv:fix/prevent-cross-cluster-lb-hijack

Conversation

@lazydiv

@lazydiv lazydiv commented Jun 3, 2026

Copy link
Copy Markdown

Summary

Fixes #916 | Related #556

When two DOKS clusters use the same service.beta.kubernetes.io/do-loadbalancer-name annotation, findLoadBalancerByName() matches any LB on the account with that name — regardless of which cluster owns it. The second cluster silently claims and overwrites the first cluster's LB. When the clusters are in different regions, this destroys the original LB and permanently loses its IP.

Changes

  • Add a clusterID parameter to findLoadBalancerByName() and findLoadBalancerID()
  • Before returning a name match, verify the LB carries the current cluster's k8s:<clusterID> tag
  • If the tag is missing, skip the LB and log a warning
  • The CCM then falls through to create a new LB, which will fail with a proper name-conflict or quota error from the DO API

Test plan

  • All existing tests pass
  • Verified with go build ./... and go test ./cloud-controller-manager/do/...

When two clusters use the same do-loadbalancer-name annotation, the CCM
finds and claims the existing LB by name without verifying ownership.
This can destroy the original LB and permanently lose its IP when the
clusters are in different regions.

Add a cluster tag check to findLoadBalancerByName so that a LB is only
matched when it carries the current cluster's k8s tag. If the tag is
missing, the LB is skipped and the CCM falls through to create a new
one, which will fail with a proper name-conflict or quota error from
the API.

Fixes digitalocean#916
Related digitalocean#556
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Duplicate do-loadbalancer-name across clusters destroys existing LB and permanently loses IP

1 participant