From 3adff405eb2dba89b7e5fad6ed11b1dc95d0b2c7 Mon Sep 17 00:00:00 2001 From: darkobas Date: Mon, 17 Aug 2026 21:29:28 +0200 Subject: [PATCH 1/2] fix(bee): restrict permissions on mounted secrets and generated keys Set defaultMode 0440 on the bee-secret, bee-libp2p and bee-swarm secret volumes. Without it Kubernetes mounts them 0644, so the wallet password and key material carry a world-readable mode. podSecurityContext.fsGroup 999 keeps them readable by the bee process. Reorder the libp2p and swarm init containers to write the key file, chmod it 0600, and only then chown -R. Previously the chown ran before the file was written, so swarm.key and libp2p_v2.key persisted on the volume as root-owned and 0644. Co-Authored-By: Claude Opus 5 --- charts/bee/templates/statefulset.yaml | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/charts/bee/templates/statefulset.yaml b/charts/bee/templates/statefulset.yaml index 9304d9f..a0ed5d3 100644 --- a/charts/bee/templates/statefulset.yaml +++ b/charts/bee/templates/statefulset.yaml @@ -64,10 +64,11 @@ spec: - -c - > mkdir -p /home/bee/.bee/keys; - chown -R 999:999 /home/bee/.bee/keys; export KEY=$(cat /tmp/bee/libp2p.map | grep $(hostname): | cut -d' ' -f2); - if [ -z "${KEY}" ]; then exit 0; fi; + if [ -z "${KEY}" ]; then chown -R 999:999 /home/bee/.bee/keys; exit 0; fi; printf '%s' "${KEY}" > /home/bee/.bee/keys/libp2p_v2.key; + chmod 600 /home/bee/.bee/keys/libp2p_v2.key; + chown -R 999:999 /home/bee/.bee/keys; echo 'node initialization done'; volumeMounts: - name: data @@ -86,10 +87,11 @@ spec: - -c - > mkdir -p /home/bee/.bee/keys; - chown -R 999:999 /home/bee/.bee/keys; export KEY=$(cat /tmp/bee/swarm.map | grep $(hostname): | cut -d' ' -f2); - if [ -z "${KEY}" ]; then exit 0; fi; + if [ -z "${KEY}" ]; then chown -R 999:999 /home/bee/.bee/keys; exit 0; fi; printf '%s' "${KEY}" > /home/bee/.bee/keys/swarm.key; + chmod 600 /home/bee/.bee/keys/swarm.key; + chown -R 999:999 /home/bee/.bee/keys; echo 'node initialization done'; volumeMounts: - name: data @@ -329,6 +331,10 @@ spec: name: {{ template "bee.fullname" . }} - name: bee-secret secret: + ## 0440: owner root, group-readable via podSecurityContext.fsGroup (999). + ## Without this, Kubernetes defaults to 0644 and the wallet password is + ## world-readable by every container in the pod. + defaultMode: 0440 {{- if .Values.existingSecret }} secretName: {{ .Values.existingSecret }} items: @@ -343,6 +349,7 @@ spec: {{- if .Values.libp2pSettings.enabled }} - name: bee-libp2p secret: + defaultMode: 0440 secretName: {{ template "bee.libp2pKeysSecretName" . }} items: - key: {{ template "bee.libp2pKeysSecretKey" . }} @@ -351,6 +358,7 @@ spec: {{- if .Values.swarmSettings.enabled }} - name: bee-swarm secret: + defaultMode: 0440 secretName: {{ template "bee.swarmKeysSecretName" . }} items: - key: {{ template "bee.swarmKeysSecretKey" . }} From 9571662d46f9e14ca87bca50be4c111d96590b2f Mon Sep 17 00:00:00 2001 From: darkobas Date: Mon, 17 Aug 2026 23:01:23 +0200 Subject: [PATCH 2/2] chore(bee): bump chart version to 0.17.4 Required by CI: ct lint enforces a version increment for changed charts. Co-Authored-By: Claude Opus 5 --- charts/bee/Chart.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/charts/bee/Chart.yaml b/charts/bee/Chart.yaml index 5133d1b..5033796 100644 --- a/charts/bee/Chart.yaml +++ b/charts/bee/Chart.yaml @@ -1,7 +1,7 @@ apiVersion: v2 appVersion: 2.5.0 name: bee -version: 0.17.3 +version: 0.17.4 kubeVersion: ">=1.19.0-0" description: Ethereum Swarm Bee Helm chart for Kubernetes home: https://www.ethswarm.org