Skip to content

Commit

Permalink
Ensure defaultMode=0400 for projected volumes containing secrets
Browse files Browse the repository at this point in the history
Follow cilium/cilium#17367:

It seems that these volumes were wrongly given permission 420 instead of
0400, giving write permission to the group. In all instances, the actual
volumeMounts were set to readonly so this change should have no effect
but better be more cautious about permissions for secrets.

Reported-by: Robin Hahling <[email protected]>
Signed-off-by: Tobias Klauser <[email protected]>
  • Loading branch information
tklauser committed Sep 14, 2021
1 parent 0441b3e commit 39df2bb
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion clustermesh/clustermesh.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ var (
replicas = int32(1)
deploymentMaxSurge = intstr.FromInt(1)
deploymentMaxUnavailable = intstr.FromInt(1)
secretDefaultMode = int32(420)
secretDefaultMode = int32(0400)
)

var clusterRole = &rbacv1.ClusterRole{
Expand Down
2 changes: 2 additions & 0 deletions hubble/relay.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ const (
)

var (
secretDefaultMode = int32(0400)
relayReplicas = int32(1)
relayPortIntstr = intstr.FromInt(defaults.RelayPort)
deploymentMaxSurge = intstr.FromInt(1)
Expand Down Expand Up @@ -168,6 +169,7 @@ func (k *K8sHubble) generateRelayDeployment() *appsv1.Deployment {
Name: "tls",
VolumeSource: corev1.VolumeSource{
Projected: &corev1.ProjectedVolumeSource{
DefaultMode: &secretDefaultMode,
Sources: []corev1.VolumeProjection{
{
Secret: &corev1.SecretProjection{
Expand Down
3 changes: 2 additions & 1 deletion install/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ var (
agentTerminationGracePeriodSeconds = int64(1)
hostPathDirectoryOrCreate = corev1.HostPathDirectoryOrCreate
hostPathFileOrCreate = corev1.HostPathFileOrCreate
secretDefaultMode = int32(420)
secretDefaultMode = int32(0400)
operatorReplicas = int32(1)
operatorMaxSurge = intstr.FromInt(1)
operatorMaxUnavailable = intstr.FromInt(1)
Expand Down Expand Up @@ -594,6 +594,7 @@ func (k *K8sInstaller) generateAgentDaemonSet() *appsv1.DaemonSet {
Name: "hubble-tls",
VolumeSource: corev1.VolumeSource{
Projected: &corev1.ProjectedVolumeSource{
DefaultMode: &secretDefaultMode,
Sources: []corev1.VolumeProjection{
{
Secret: &corev1.SecretProjection{
Expand Down

0 comments on commit 39df2bb

Please sign in to comment.