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

Explicitly declare allowPrivilegeEscalation to false in all components #1593

Merged
merged 2 commits into from
Jan 24, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ kubeconform: crdschemas manifests $(KUBECONFORM_BIN)

.PHONY: kubescape
kubescape: $(KUBESCAPE_BIN) ## Runs a security analysis on generated manifests - failing if risk score is above 40%
$(KUBESCAPE_BIN) scan -s framework -t 40 nsa manifests/*.yaml
$(KUBESCAPE_BIN) scan -s framework -t 30 nsa manifests/*.yaml

.PHONY: fmt
fmt: $(JSONNETFMT_BIN)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ function(params) {
} else {
runAsNonRoot: true,
runAsUser: 65534,
allowPrivilegeEscalation: false,
},
volumeMounts: [{
mountPath: '/etc/blackbox_exporter/',
Expand All @@ -188,7 +189,11 @@ function(params) {
'--volume-dir=/etc/blackbox_exporter/',
],
resources: bb._config.resources,
securityContext: { runAsNonRoot: true, runAsUser: 65534 },
securityContext: {
runAsNonRoot: true,
runAsUser: 65534,
allowPrivilegeEscalation: false,
},
terminationMessagePath: '/dev/termination-log',
terminationMessagePolicy: 'FallbackToLogsOnError',
volumeMounts: [{
Expand Down
16 changes: 16 additions & 0 deletions jsonnet/kube-prometheus/components/grafana.libsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -83,4 +83,20 @@ function(params)
}],
},
},

// FIXME(ArthurSens): The override adding 'allowPrivilegeEscalation: false' can be deleted when
// https://github.com/brancz/kubernetes-grafana/pull/128 gets merged.
deployment+: {
spec+: {
template+: {
spec+: {
containers: std.map(function(c) c {
securityContext+: {
allowPrivilegeEscalation: false,
},
}, super.containers),
},
},
},
},
}
Original file line number Diff line number Diff line change
Expand Up @@ -61,5 +61,6 @@ function(params) {
runAsUser: 65532,
runAsGroup: 65532,
runAsNonRoot: true,
allowPrivilegeEscalation: false,
},
}
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,8 @@ function(params) (import 'github.com/kubernetes/kube-state-metrics/jsonnet/kube-
image: ksm._config.kubeRbacProxyImage,
}),

// FIXME(ArthurSens): The override adding 'allowPrivilegeEscalation: false' can be deleted when
// https://github.com/kubernetes/kube-state-metrics/pull/1668 gets merged.
deployment+: {
spec+: {
template+: {
Expand All @@ -133,6 +135,9 @@ function(params) (import 'github.com/kubernetes/kube-state-metrics/jsonnet/kube-
readinessProbe:: null,
args: ['--host=127.0.0.1', '--port=8081', '--telemetry-host=127.0.0.1', '--telemetry-port=8082'],
resources: ksm._config.resources,
securityContext+: {
allowPrivilegeEscalation: false,
},
}, super.containers) + [kubeRbacProxyMain, kubeRbacProxySelf],
},
},
Expand Down
3 changes: 3 additions & 0 deletions jsonnet/kube-prometheus/components/node-exporter.libsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,9 @@ function(params) {
{ name: 'root', mountPath: '/host/root', mountPropagation: 'HostToContainer', readOnly: true },
],
resources: ne._config.resources,
securityContext: {
allowPrivilegeEscalation: false,
},
};

local kubeRbacProxy = krp({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,9 @@ function(params) {
{ name: 'volume-serving-cert', mountPath: '/var/run/serving-cert', readOnly: false },
{ name: 'config', mountPath: '/etc/adapter', readOnly: false },
],
securityContext: {
allowPrivilegeEscalation: false,
},
};

{
Expand Down
3 changes: 3 additions & 0 deletions manifests/blackboxExporter-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ spec:
cpu: 10m
memory: 20Mi
securityContext:
allowPrivilegeEscalation: false
runAsNonRoot: true
runAsUser: 65534
volumeMounts:
Expand All @@ -61,6 +62,7 @@ spec:
cpu: 10m
memory: 20Mi
securityContext:
allowPrivilegeEscalation: false
runAsNonRoot: true
runAsUser: 65534
terminationMessagePath: /dev/termination-log
Expand All @@ -87,6 +89,7 @@ spec:
cpu: 10m
memory: 20Mi
securityContext:
allowPrivilegeEscalation: false
runAsGroup: 65532
runAsNonRoot: true
runAsUser: 65532
Expand Down
2 changes: 2 additions & 0 deletions manifests/grafana-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ spec:
requests:
cpu: 100m
memory: 100Mi
securityContext:
allowPrivilegeEscalation: false
volumeMounts:
- mountPath: /var/lib/grafana
name: grafana-storage
Expand Down
3 changes: 3 additions & 0 deletions manifests/kubeStateMetrics-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ spec:
cpu: 10m
memory: 190Mi
securityContext:
allowPrivilegeEscalation: false
runAsUser: 65534
- args:
- --logtostderr
Expand All @@ -60,6 +61,7 @@ spec:
cpu: 20m
memory: 20Mi
securityContext:
allowPrivilegeEscalation: false
runAsGroup: 65532
runAsNonRoot: true
runAsUser: 65532
Expand All @@ -81,6 +83,7 @@ spec:
cpu: 10m
memory: 20Mi
securityContext:
allowPrivilegeEscalation: false
runAsGroup: 65532
runAsNonRoot: true
runAsUser: 65532
Expand Down
3 changes: 3 additions & 0 deletions manifests/nodeExporter-daemonset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ spec:
requests:
cpu: 102m
memory: 180Mi
securityContext:
allowPrivilegeEscalation: false
volumeMounts:
- mountPath: /host/sys
mountPropagation: HostToContainer
Expand Down Expand Up @@ -76,6 +78,7 @@ spec:
cpu: 10m
memory: 20Mi
securityContext:
allowPrivilegeEscalation: false
runAsGroup: 65532
runAsNonRoot: true
runAsUser: 65532
Expand Down
2 changes: 2 additions & 0 deletions manifests/prometheusAdapter-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ spec:
requests:
cpu: 102m
memory: 180Mi
securityContext:
allowPrivilegeEscalation: false
volumeMounts:
- mountPath: /tmp
name: tmpfs
Expand Down
1 change: 1 addition & 0 deletions manifests/prometheusOperator-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ spec:
cpu: 10m
memory: 20Mi
securityContext:
allowPrivilegeEscalation: false
runAsGroup: 65532
runAsNonRoot: true
runAsUser: 65532
Expand Down