Skip to content

fix: Refuse to overwrite foreign objects from TrustStore reconciler#707

Open
dervoeti wants to merge 2 commits into
mainfrom
fix/truststore-foreign-object-hijack
Open

fix: Refuse to overwrite foreign objects from TrustStore reconciler#707
dervoeti wants to merge 2 commits into
mainfrom
fix/truststore-foreign-object-hijack

Conversation

@dervoeti
Copy link
Copy Markdown
Member

@dervoeti dervoeti commented May 18, 2026

Description

TLDR: Write access on TrustStore allows write access for ConfigMap or Secret in the same namespace

The TrustStore reconciler writes its output ConfigMap or Secret using the TrustStore CR's own name and applies it via SSA with force=true. Combined with the operator's cluster-wide write permissions on ConfigMaps and Secrets, this lets any principal who can create a TrustStore in a namespace cause the operator to overwrite the contents of any pre-existing same-named ConfigMap or Secret in that namespace, stealing ownership and attaching a controller OwnerReference that links the hijacked object to the TrustStore CR for cascade delete.

A good showcase is the auto-published kube-root-ca.crt ConfigMap:
A tenant with create on truststores.secrets.stackable.tech in their namespace can create a TrustStore named kube-root-ca.crt, overwrite the CA bundle every pod in the namespace uses to verify in-cluster TLS, and cascade-delete that ConfigMap by deleting the TrustStore. This allows a) MITM attacks (hard because you need to modify DNS resolution of the Pods) and b) potentially crashing existing Pods on restart because kube-root-ca.crt is corrupted.

The same applies to any ConfigMap or Secret in the same namespace whose name the attacker can guess.

Fix

Before applying, look up the existing target. If the object already exists and is not owned by the current TrustStore, refuse the reconciliation.

Definition of Done Checklist

  • Not all of these items are applicable to all PRs, the author should update this template to only leave the boxes in that are relevant
  • Please make sure all these things are done and tick the boxes

Author

  • Changes are OpenShift compatible
  • CRD changes approved
  • CRD documentation for all fields, following the style guide.
  • Helm chart can be installed and deployed operator works
  • Integration tests passed (for non trivial changes)
  • Changes need to be "offline" compatible
  • Links to generated (nightly) docs added
  • Release note snippet added

Reviewer

  • Code contains useful comments
  • Code contains useful logging statements
  • (Integration-)Test cases added
  • Documentation added or updated. Follows the style guide.
  • Changelog updated
  • Cargo.toml only contains references to git tags (not specific commits or branches)

Acceptance

  • Feature Tracker has been updated
  • Proper release label has been added
  • Links to generated (nightly) docs added
  • Release note snippet added
  • Add type/deprecation label & add to the deprecation schedule
  • Add type/experimental label & add to the experimental features tracker

@dervoeti dervoeti force-pushed the fix/truststore-foreign-object-hijack branch 2 times, most recently from b3fc25f to 5b555d9 Compare May 18, 2026 13:01
@dervoeti dervoeti force-pushed the fix/truststore-foreign-object-hijack branch from 5b555d9 to 940dde4 Compare May 18, 2026 13:02
sweb
sweb previously approved these changes May 18, 2026
Copy link
Copy Markdown
Member

@sweb sweb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm - but I primarily did this to dive into the code base, so grains of salt - I also tried out the review skill on this.

Comment thread rust/operator-binary/src/truststore_controller.rs Outdated
Comment thread rust/operator-binary/src/truststore_controller.rs Outdated
Comment thread rust/operator-binary/src/truststore_controller.rs Outdated
Comment thread rust/operator-binary/src/truststore_controller.rs
@dervoeti dervoeti moved this to Development: Waiting for Review in Stackable Engineering May 18, 2026
@dervoeti dervoeti self-assigned this May 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Development: Waiting for Review

Development

Successfully merging this pull request may close these issues.

2 participants