Skip to content
This repository has been archived by the owner on Apr 11, 2024. It is now read-only.

Commit

Permalink
fix: use a LocalObjectReference for credentials Secret (#37)
Browse files Browse the repository at this point in the history
Using a cross-namespace objectRef in the cluster API
can lead to privilege escalation.
A user with RBAC to read Secrets in one namespace can create a cluster,
and copy any Secret from any other namespace to their workload cluster.
  • Loading branch information
dkoshkin authored Apr 9, 2024
1 parent e78e6f9 commit cb8fadb
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 7 deletions.
5 changes: 1 addition & 4 deletions api/v1alpha1/addon_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ type CSIProvider struct {
Strategy AddonStrategy `json:"strategy"`

// +optional
Credentials *corev1.SecretReference `json:"credentials,omitempty"`
Credentials *corev1.LocalObjectReference `json:"credentials,omitempty"`
}

type StorageClassConfig struct {
Expand Down Expand Up @@ -257,9 +257,6 @@ func (CSIProvider) VariableSchema() clusterv1.VariableSchema {
"name": {
Type: "string",
},
"namespace": {
Type: "string",
},
},
},
"storageClassConfig": {
Expand Down
2 changes: 1 addition & 1 deletion api/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions pkg/handlers/generic/lifecycle/csi/nutanix-csi/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,8 @@ func (n *NutanixCSI) Apply(
Kind: "Secret",
},
ObjectMeta: metav1.ObjectMeta{
Namespace: provider.Credentials.Name,
Name: provider.Credentials.Namespace,
Name: provider.Credentials.Name,
Namespace: req.Cluster.Namespace,
},
}
err := n.client.Get(
Expand Down

0 comments on commit cb8fadb

Please sign in to comment.