Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[security fix] Refactor intree security model #1509

Merged
merged 3 commits into from Apr 22, 2020

Conversation

lpabon
Copy link
Member

@lpabon lpabon commented Apr 15, 2020

What this PR does / why we need it:
From the commit:
Support for multitenancy in intree Kubernetes

This change fixes a security issue where the pvc user could
maliciously use the secret located in a namespace they cannot
access. Instead this patch changes the model to the CSI model
which is based on using the StorageClass as the source of truth
on the location of the sercret which contains the authentication
token.

This change makes it possible to use the same style as CSI where the location of the secret and its name are set in the storage class and not in the PVC.

Sample StorageClasses are under test/setup/assets/

Also:
BATS KinD test framework

This test framework allows testing of openstorage as a
provisioner for the Portworx intree Kubernetes driver. With
this model, we can automate test openstorage authentication model
on Kubernetes

Reviewers

I have broken the PR into three commits:

  1. Vendor updates
  2. BATS KinD framework
  3. Code modifications

@lpabon lpabon force-pushed the intree-multitenant-2 branch 7 times, most recently from fa30066 to 486d00a Compare April 21, 2020 19:43
csi/node.go Outdated
@@ -161,6 +162,7 @@ func (s *OsdCsiServer) NodePublishVolume(
}
return nil, err
}
logrus.Infof("csi: Called mount for volume %s", volumeId)
Copy link
Contributor

Choose a reason for hiding this comment

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

Did you mean to leave these two log lines? this one seems repetitive with L167

Copy link
Member Author

Choose a reason for hiding this comment

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

Doh! this is a debugging line. I will remove it.

Copy link
Contributor

@ggriffiths ggriffiths left a comment

Choose a reason for hiding this comment

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

Mostly good, just was question about CSI log lines.

Copy link
Contributor

@adityadani adityadani left a comment

Choose a reason for hiding this comment

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

lgtm

}

// Allow ${pvc.namespace} to be set in the storage class
namespaceParams := map[string]string{"pvc.namespace": pvc.GetNamespace()}
Copy link
Contributor

Choose a reason for hiding this comment

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

shouldn't this be done only when len(secretNamespaceValue) > 0 ?

Copy link
Member Author

Choose a reason for hiding this comment

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

The ResolveTemplate function is only using this as an input to the template parser. In other words, the result will be the same if secretNamespaceValue is "" since there is nothing to replace.


// Get secret name
nameParams := make(map[string]string)
// Allow ${pvc.annotations['pvcNameKey']} to be set in the storage class
Copy link
Contributor

Choose a reason for hiding this comment

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

What will the annotation look like in this case ?

Copy link
Member Author

Choose a reason for hiding this comment

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

cmd/osd/main.go Outdated
@@ -183,6 +183,11 @@ func main() {
Usage: "CSI Driver name",
Value: "",
},
cli.StringFlag{
Name: "secrets-type",
Usage: "Secrets manager type: k8s",
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: it could be any secrets manager and not just k8s

Copy link
Member Author

Choose a reason for hiding this comment

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

True, I will add more information

* Needed to include new updated portworx/sched-ops change

Signed-off-by: Luis Pabón <luis@portworx.com>
This test framework allows testing of openstorage as a
provisioner for the Portworx intree Kubernetes driver. With
this model, we can automate test openstorage authentication model
on Kubernetes

Signed-off-by: Luis Pabón <luis@portworx.com>
This change fixes a security issue where the pvc user could
maliciously use the secret located in a namespace they cannot
access. Instead this patch changes the model to the CSI model
which is based on using the StorageClass as the source of truth
on the location of the sercret which contains the authentication
token.

Signed-off-by: Luis Pabón <luis@portworx.com>
@lpabon lpabon merged commit 9db49f2 into libopenstorage:master Apr 22, 2020
@lpabon lpabon deleted the intree-multitenant-2 branch April 22, 2020 19:34
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.

None yet

3 participants