Skip to content

Commit 82ed0cd

Browse files
committed
Mounted cloud credentials should not be world-readable (vmware-tanzu#8919)
Signed-off-by: Scott Seago <[email protected]>
1 parent 1017d7a commit 82ed0cd

File tree

4 files changed

+9
-1
lines changed

4 files changed

+9
-1
lines changed

changelogs/unreleased/9094-sseago

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Mounted cloud credentials should not be world-readable

internal/credentials/file_store.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,8 @@ func (n *namespacedFileStore) Path(selector *corev1api.SecretKeySelector) (strin
7171

7272
keyFilePath := filepath.Join(n.fsRoot, fmt.Sprintf("%s-%s", selector.Name, selector.Key))
7373

74-
file, err := n.fs.OpenFile(keyFilePath, os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0644)
74+
// owner RW perms, group R perms, no public perms
75+
file, err := n.fs.OpenFile(keyFilePath, os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0640)
7576
if err != nil {
7677
return "", errors.Wrap(err, "unable to open credentials file for writing")
7778
}

pkg/install/daemonset.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import (
2323
appsv1 "k8s.io/api/apps/v1"
2424
corev1 "k8s.io/api/core/v1"
2525
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
26+
"k8s.io/utils/ptr"
2627

2728
"github.com/vmware-tanzu/velero/internal/velero"
2829
)
@@ -177,6 +178,8 @@ func DaemonSet(namespace string, opts ...podTemplateOption) *appsv1.DaemonSet {
177178
Name: "cloud-credentials",
178179
VolumeSource: corev1.VolumeSource{
179180
Secret: &corev1.SecretVolumeSource{
181+
// read-only for Owner, Group, Public
182+
DefaultMode: ptr.To(int32(0444)),
180183
SecretName: "cloud-credentials",
181184
},
182185
},

pkg/install/deployment.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import (
2424
appsv1 "k8s.io/api/apps/v1"
2525
corev1 "k8s.io/api/core/v1"
2626
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
27+
"k8s.io/utils/ptr"
2728

2829
"github.com/vmware-tanzu/velero/internal/velero"
2930
"github.com/vmware-tanzu/velero/pkg/builder"
@@ -404,6 +405,8 @@ func Deployment(namespace string, opts ...podTemplateOption) *appsv1.Deployment
404405
Name: "cloud-credentials",
405406
VolumeSource: corev1.VolumeSource{
406407
Secret: &corev1.SecretVolumeSource{
408+
// read-only for Owner, Group, Public
409+
DefaultMode: ptr.To(int32(0444)),
407410
SecretName: "cloud-credentials",
408411
},
409412
},

0 commit comments

Comments
 (0)