Skip to content

Commit 0fb72d7

Browse files
authored
chore(agent0-connector): remove redundant internal cm restrictions (#1347)
Reading ConfigMaps is disallowed via RBAC in the default clusterrole for agent0-connector, but can be allowed via custom rules for users that do not store sensitive data in config maps in their clusters. This removes the hardcoded checks that disallowed access to configmaps within agent0-connector itself.
1 parent 9bb9723 commit 0fb72d7

13 files changed

Lines changed: 805 additions & 335 deletions

CLAUDE.md

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -106,20 +106,9 @@ and the output formats that can reshape a value (`-o go-template/jsonpath/custom
106106
because their output cannot be redacted. A credential-bearing CRD that is missing from the list therefore stays fully
107107
readable through those formats as well.
108108

109-
`dash0ResourceTypesWithSecrets` is one of two lists behind `targetsResourceTypeWithSecrets`. The other is
109+
`dash0ResourceTypesWithSecrets` is one of three lists behind `targetsResourceTypeWithSecrets`. The second is
110110
`workloadResourceTypes`, the Kubernetes resource types that carry a pod spec (pods, deployments, daemonsets, jobs,
111-
controller revisions, ...). Any workload can hold a credential in the literal value of an environment variable, so
112-
`redactEnvVarValues` replaces the value of every environment variable of a pod spec, and these resource types are
113-
restricted to the same output formats as the Dash0 custom resources. An environment variable that sources its value via
114-
`valueFrom` is left untouched, and so are the header values of the HTTP probes and lifecycle hooks of a pod spec, which
115-
are redacted via the same `httpHeaders` case as the header values of an export.
116-
117-
For every resource type that can contain secrets, `--sort-by` is restricted as well (`unsafeSortByRequested`,
118-
`unsafeSortByOfSensitiveResourceRequested`): kubectl evaluates the expression against the resources before the
119-
connector sees them, so sorting by a redacted field leaks its order, and a filter expression such as
120-
`{.spec.containers[0].env[?(@.value>"S")].name}` turns a match into a comparison oracle that reveals the value over
121-
several requests. Only a plain path below `metadata` or `status` is accepted, except `metadata.annotations`, which
122-
holds the verbatim copy of the spec that `kubectl apply` leaves behind.
111+
controller revisions, ...). The third is `configMapResourceTypes`.
123112

124113
When adding or changing a CRD, check all four lists above - grep for `dash0ResourceTypesWithSecrets`,
125114
`credentialFieldsPerConfigObject` and `urlFieldsPerConfigObject`, and read the `case` clauses of

helm-chart/dash0-operator/files/agent0-connector-default-cluster-role-rules.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@
1515
#
1616
# Users can replace these rules entirely via the Helm value operator.agent0Connector.clusterRole.rules.
1717

18-
# Read-only access to core API group resource types. Resources which can hold sensitive user data (secrets, config maps)
19-
# are deliberately absent, so that they cannot be read at all, independent of the validation & redaction the
20-
# agent0-connector applies to a command request.
18+
# Read-only access to core API group resource types. Configmaps are absent as a defensive default value, since
19+
# configmaps can hold sensitive values in some setups. Users that want to allow access to configmaps can do so by
20+
# providing custom RBAC rules for agent0-connector.
2121
- apiGroups:
2222
- ""
2323
resources:

helm-chart/dash0-operator/values.yaml

Lines changed: 73 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1288,10 +1288,12 @@ operator:
12881288
# Additional annotations for the pods of the Edge Proxy deployment managed by the operator.
12891289
podAnnotations: {}
12901290

1291-
# Settings related to the Agent0 connector (experimental/beta).
1291+
# Settings related to the Agent0 connector (experimental).
12921292
agent0Connector:
12931293

1294-
# The agent0-connector feature is currently experimental, do not enable it (yet).
1294+
# The agent0-connector feature is currently experimental, do not enable it.
1295+
#
1296+
# All other settings in operator.agent0Connector will be ignored if operator.agent0Connector.enabled is false.
12951297
enabled: false
12961298

12971299
# The address (host:port) of the Dash0 backend service the agent0-connector pod connects to. This value is mandatory
@@ -1323,8 +1325,8 @@ operator:
13231325
# secret with the command above (see property "name"), you would set the property to "token".
13241326
key:
13251327

1326-
# Disables TLS for the agent0-connector workload's connection to the Dash0 backend, connecting via plaintext
1327-
# instead. This is only intended for local development.
1328+
# Disables TLS for the agent0-connector's connection to the Dash0 backend, connecting via plaintext instead. This
1329+
# is only intended for local development.
13281330
insecure: false
13291331

13301332
# Resource settings for the agent0-connector container of the agent0-connector deployment managed by the operator.
@@ -1341,6 +1343,47 @@ operator:
13411343
requests:
13421344
memory: 32Mi
13431345

1346+
# Additional labels to be set on the agent0-connector deployment managed by the operator.
1347+
labels: {}
1348+
1349+
# Additional annotations to be set on the agent0-connector deployment managed by the operator.
1350+
annotations: {}
1351+
1352+
# Additional labels to be set on the agent0-connector deployment pods managed by the operator.
1353+
podLabels: {}
1354+
1355+
# Additional annotations to be set on the agent0-connector deployment pods managed by the operator.
1356+
podAnnotations: {}
1357+
1358+
# An array of tolerations for the agent0-connector deployment managed by the operator. This can be used to make sure
1359+
# that the agent0-connector pod can be scheduled on nodes where it would not be scheduled otherwise due to
1360+
# Kubernetes taints.
1361+
# Example:
1362+
# tolerations:
1363+
# - key: "key1"
1364+
# operator: "Equal"
1365+
# value: "value1"
1366+
# effect: "NoSchedule"
1367+
# - key: "key2"
1368+
# operator: "Exists"
1369+
# effect: "NoSchedule"
1370+
tolerations: []
1371+
1372+
# The nodeAffinity for the agent0-connector deployment managed by the operator. This can be used to constrain which
1373+
# nodes the agent0-connector pod will be scheduled on.
1374+
#
1375+
# See https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/#node-affinity
1376+
nodeAffinity:
1377+
requiredDuringSchedulingIgnoredDuringExecution:
1378+
nodeSelectorTerms:
1379+
- matchExpressions:
1380+
- key: "dash0.com/enable"
1381+
operator: "NotIn"
1382+
values: ["false"]
1383+
- key: "kubernetes.io/os"
1384+
operator: "In"
1385+
values: ["linux"]
1386+
13441387
# Settings for the cluster role the operator creates for the agent0-connector.
13451388
clusterRole:
13461389

@@ -1364,14 +1407,33 @@ operator:
13641407
# "kubectl auth can-i" requires and which cannot modify cluster state. Any other verb, in particular a write verb
13651408
# like "create", "update", "patch" or "delete", as well as the wildcard "*", makes the Helm installation fail.
13661409
#
1367-
# Note that reading the content of Kubernetes secrets is rejected by the agent0-connector itself, independent of
1368-
# the rules configured here.
1410+
# Allowing access to additional resources can have security implications. Only grant access to additional
1411+
# resources types when you are confident that it cannot be used to exfiltrate sensitive data (auth tokens,
1412+
# credentials, API secrets etc.) from the cluster. Failure to do so makes these secrets accessible to anyone who
1413+
# has access to your Dash0 organization. The agent0-connector component uses a set of restrictions and redaction
1414+
# mechanisms to prevent leaking secrets. The following are redacted:
1415+
# * the environment variable values and probe headers of any workload,
1416+
# * all credential fields in any of the Dash0 custom resources.
1417+
# Automatic redaction is also applied to the JSON or YAML content of ConfigMaps, if access to ConfigMaps is
1418+
# granted via custom RBAC rules. (ConfigMaps are inaccessible under the default RBAC rules.) The redaction of
1419+
# ConfigMap content is best-effort: the connector parses every value of data and binaryData that is a JSON or
1420+
# YAML object or list, including a YAML value that holds several documents, and replaces the values of certain
1421+
# key names (token, password, headers, queryParameters, httpHeaders). The values of binaryData are base64 and are
1422+
# decoded before they are inspected and encoded again afterwards. A credential in a format the connector cannot
1423+
# parse (a properties file, a shell script), or under a key name it does not know, is returned unredacted. That
1424+
# is to say, only allow access to ConfigMaps if they do not contain secrets, or if the redaction described here
1425+
# is sufficient.
1426+
#
1427+
# Note that a ConfigMap value the connector did redact something in is re-rendered as a whole, which drops its
1428+
# comments and normalizes its key order and scalar notation. A value nothing was redacted from is returned byte
1429+
# for byte.
13691430
#
1370-
# For every other resource type, the agent0-connector redacts the credentials it knows about from a response
1371-
# before it leaves the cluster. Secret redaction is applied to Dash0 custom resources and the Kubernetes resource
1372-
# types which carry a pod spec (environment variable values are redacted). Granting access to a resource type
1373-
# outside that set, for example a third-party custom resource which holds a credential, returns its content
1374-
# unredacted.
1431+
# The content of every resource type outside the set mentioned above (standard Kubernetes workload resources,
1432+
# Dash0 custom resources, and JSON/YAML ConfigMap content) is returned verbatim, i.e. unredacted.
1433+
#
1434+
# Reading the *content* of Kubernetes secrets is rejected by the agent0-connector itself, independent of
1435+
# the rules configured here. (Listing secrets and checking for their presence is allowed, if the rules list the
1436+
# secrets resource type - the default rules do not include access to secrets).
13751437
#
13761438
# By default, Kubernetes grants the verb "get" for the API discovery URLs (/api, /apis, /openapi/v3, ..., all of
13771439
# which are required for this component) to the group system:authenticated via the system:discovery cluster role
@@ -1391,44 +1453,3 @@ operator:
13911453
# resources: ["selfsubjectaccessreviews", "selfsubjectrulesreviews"]
13921454
# verbs: ["create"]
13931455
rules: []
1394-
1395-
# Additional labels to be set on the agent0-connector deployment managed by the operator.
1396-
labels: {}
1397-
1398-
# Additional annotations to be set on the agent0-connector deployment managed by the operator.
1399-
annotations: {}
1400-
1401-
# Additional labels to be set on the agent0-connector deployment pods managed by the operator.
1402-
podLabels: {}
1403-
1404-
# Additional annotations to be set on the agent0-connector deployment pods managed by the operator.
1405-
podAnnotations: {}
1406-
1407-
# An array of tolerations for the agent0-connector deployment managed by the operator. This can be used to make sure
1408-
# that the agent0-connector pod can be scheduled on nodes where it would not be scheduled otherwise due to
1409-
# Kubernetes taints.
1410-
# Example:
1411-
# tolerations:
1412-
# - key: "key1"
1413-
# operator: "Equal"
1414-
# value: "value1"
1415-
# effect: "NoSchedule"
1416-
# - key: "key2"
1417-
# operator: "Exists"
1418-
# effect: "NoSchedule"
1419-
tolerations: []
1420-
1421-
# The nodeAffinity for the agent0-connector deployment managed by the operator. This can be used to constrain which
1422-
# nodes the agent0-connector pod will be scheduled on.
1423-
#
1424-
# See https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/#node-affinity
1425-
nodeAffinity:
1426-
requiredDuringSchedulingIgnoredDuringExecution:
1427-
nodeSelectorTerms:
1428-
- matchExpressions:
1429-
- key: "dash0.com/enable"
1430-
operator: "NotIn"
1431-
values: ["false"]
1432-
- key: "kubernetes.io/os"
1433-
operator: "In"
1434-
values: ["linux"]

images/agent0-connector/src/go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@ go 1.27.0
55
require (
66
go.opentelemetry.io/otel v1.45.0
77
go.opentelemetry.io/otel/trace v1.45.0
8+
go.yaml.in/yaml/v2 v2.4.2
89
google.golang.org/grpc v1.83.1
910
google.golang.org/protobuf v1.36.12
1011
sigs.k8s.io/yaml v1.6.0
1112
)
1213

1314
require (
1415
github.com/cespare/xxhash/v2 v2.3.0 // indirect
15-
go.yaml.in/yaml/v2 v2.4.2 // indirect
1616
golang.org/x/net v0.56.0 // indirect
1717
golang.org/x/sys v0.46.0 // indirect
1818
golang.org/x/text v0.38.0 // indirect

0 commit comments

Comments
 (0)