fix: refuse to overwrite foreign services#393
Open
dervoeti wants to merge 1 commit into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
TLDR: Write access on Listener allows write access for any Service in the same namespace.
The Listener reconciler writes its output Service using the Listener CR's own name and applies it via server-side apply with force=true (through
ClusterResources::add). Combined with the operator's cluster-wide write permissions on Services, this lets any principal who can create a Listener in a namespace cause the operator to overwrite the contents of any pre-existing same-named Service in that namespace, stealing ownership and attaching a controllerOwnerReferencethat links the hijacked object to the Listener CR for cascade delete.A tenant with create on
listeners.listeners.stackable.techin their namespace can create a Listener named after an existing Service and:spec.selectorandspec.ports(the selector is derived from theattacker-controlled
spec.extraPodSelectorLabels), pointing it at attacker pods, andThis is the same class of issue as the
TrustStorehijack fixed in stackabletech/secret-operator#707. The reach is bounded to namespaces where the principal can create Listeners (normally their own), since the output Service is always created in the Listener's own namespace.Fix
Before applying, look up the existing target Service. If the object already exists and is not owned by the current Listener (no
controller
OwnerReferencematching this Listener's kind, API group and UID), refuse the reconciliation.Definition of Done Checklist
Author
Reviewer
Acceptance
type/deprecationlabel & add to the deprecation scheduletype/experimentallabel & add to the experimental features tracker