Skip to content

Agent Mesh

policy: fail closed on the shipped defaults instead of granting everything to everyone

Antonio Ojea7426c5888cff
diff --git a/charts/sam-mesh/tests/bootstrap-job_test.yaml b/charts/sam-mesh/tests/bootstrap-job_test.yaml
index f40723ac..d02a98bf 100644
--- a/charts/sam-mesh/tests/bootstrap-job_test.yaml
+++ b/charts/sam-mesh/tests/bootstrap-job_test.yaml
@@ -42,6 +42,27 @@ tests:
path: spec.template.spec.containers[0].args[0]
pattern: '"name": "sam:role:node".*"allowed_labels": \[\]'
+ - it: node role grants no services by default (fail closed)
+ documentSelector:
+ path: kind
+ value: Job
+ asserts:
+ - matchRegex:
+ path: spec.template.spec.containers[0].args[0]
+ pattern: '"name": "sam:role:node", "allowed_services": \[\]'
+
+ - it: node role grants only the configured services
+ documentSelector:
+ path: kind
+ value: Job
+ set:
+ bootstrap:
+ nodeServices: ["mcp://calculator", "system://sam.catalog"]
+ asserts:
+ - matchRegex:
+ path: spec.template.spec.containers[0].args[0]
+ pattern: '"name": "sam:role:node", "allowed_services": \["mcp://calculator","system://sam.catalog"\]'
+
- it: node role grants only the configured label patterns
documentSelector:
path: kind
diff --git a/charts/sam-mesh/values.yaml b/charts/sam-mesh/values.yaml
index de03c9ec..ac958cd9 100644
--- a/charts/sam-mesh/values.yaml
+++ b/charts/sam-mesh/values.yaml
@@ -180,8 +180,12 @@ console:
bootstrap:
bindings: []
- # Services sam:role:node may call
- nodeServices: ["*"]
+ # Services sam:role:node may call, as "type://name" entries (e.g.
+ # "mcp://calculator"). Any authenticated identity can claim sam:role:node,
+ # so this list is effectively mesh-wide. Empty means nodes can call nothing
+ # until a policy grants it (fail closed); never use ["*"] outside an
+ # intentionally public mesh.
+ nodeServices: []
# Label patterns ("key=value" or "key=*") sam:role:node may attest with
# --labels. Empty means nodes cannot enroll with any label (fail closed).
nodeLabels: []
diff --git a/development/kind/run.sh b/development/kind/run.sh
index e8f1e178..9b2d9099 100755
--- a/development/kind/run.sh
+++ b/development/kind/run.sh
@@ -93,6 +93,9 @@ gateway_ip() {
# deploy_chart [extra --set flags]: later flags win, so phase 2 overrides phase 1.
# TLS verification is skipped because one issuer is the kind cluster's own API server,
# served with a self-signed cert.
+# bootstrap.nodeServices is fail closed by default; this is a local dev mesh whose
+# nodes host whatever example service is being tested, so grant them everything
+# explicitly here rather than weakening the chart default.
deploy_chart() {
"${HELM}" --kube-context "${KCTX}" upgrade --install sam-mesh "${PROJECT_ROOT}/charts/sam-mesh" --timeout 10m \
--namespace "${NAMESPACE}" \
@@ -100,6 +103,7 @@ deploy_chart() {
--set controlPlane.oidcIssuer="${CONTROL_PLANE_ISSUERS//,/\\,}" \
--set controlPlane.allowedAudiences="${ALLOWED_AUDIENCES//,/\\,}" \
--set controlPlane.insecureSkipTlsVerify=true \
+ --set 'bootstrap.nodeServices={*}' \
--set gateway.enabled=true \
--set gateway.className=cloud-provider-kind \
--set gateway.adminRoute=true \
diff --git a/site/content/docs/manifests/sam-control-plane.yaml b/site/content/docs/manifests/sam-control-plane.yaml
index ca6bebf6..bf5efb5b 100644
--- a/site/content/docs/manifests/sam-control-plane.yaml
+++ b/site/content/docs/manifests/sam-control-plane.yaml
@@ -86,6 +86,13 @@ spec:
---
# The control plane starts default closed: it has no policy until one is posted.
# Seed it over the admin API, which is the only way policy is ever set.
+#
+# SECURITY: a role names what its members may call; a binding names who they
+# are. The special member "sam:system:authenticated" matches EVERY identity
+# the configured OIDC issuer will vouch for — bound to a wildcard role it
+# hands every tool on every node to anyone who can obtain a token from that
+# issuer. Never ship that combination. Grant explicit services to explicit
+# members, as below.
apiVersion: batch/v1
kind: Job
metadata:
@@ -114,10 +121,10 @@ spec:
-H "Authorization: Bearer ${SAM_ADMIN_TOKEN}" \
-d '{
"roles": [
- {"name": "public-mesh", "allowed_services": ["*"], "allowed_targets": ["*"]}
+ {"name": "demo-caller", "allowed_services": ["mcp://calculator", "system://sam.catalog"], "allowed_targets": ["user:test-user"]}
],
"bindings": [
- {"role": "public-mesh", "members": ["sam:system:authenticated"]}
+ {"role": "demo-caller", "members": ["user:test-user"]}
]
}' \
http://sam-control-plane:8080/policies
diff --git a/site/content/docs/user/control-plane-configuration.md b/site/content/docs/user/control-plane-configuration.md
index e5041b9b..3d01299d 100644
--- a/site/content/docs/user/control-plane-configuration.md
+++ b/site/content/docs/user/control-plane-configuration.md
@@ -61,6 +61,14 @@ The policy defines what endpoints and services agents are permitted to use:
> **`allowed_agents` and `allowed_targets` do different things.** `allowed_targets` controls which agents a node can send requests *to*. `allowed_agents` controls which agents a node can claim to be acting *for*. Setting `allowed_agents` to `*` lets any node with that role claim any agent identity in the mesh, so nodes log a warning when they receive such a grant.
+> **`sam:system:authenticated` means everyone your issuer vouches for.** That
+> special member matches every identity able to obtain a token from the
+> configured OIDC provider — and enrollment is open to all of them. Binding it
+> to a role with wildcard `allowed_services` therefore grants every tool on
+> every node to anyone the issuer will authenticate, which for a public
+> provider is the whole internet. Reserve it for intentionally public meshes,
+> and pair it only with narrowly scoped roles (e.g. `system://sam.catalog`).
+
### Seeding Policies via REST API
Admins manage policies by sending a JSON payload to the `/policies` endpoint.
diff --git a/site/content/docs/user/kubernetes-deployment.md b/site/content/docs/user/kubernetes-deployment.md
index e4284e87..88d6e803 100644
--- a/site/content/docs/user/kubernetes-deployment.md
+++ b/site/content/docs/user/kubernetes-deployment.md
@@ -138,7 +138,7 @@ curl -sf -X POST \
-H "Authorization: Bearer ${SAM_ADMIN_TOKEN}" \
-d '{
"roles": [
- {"name": "node-role", "allowed_services": ["*"], "allowed_targets": ["*"]}
+ {"name": "node-role", "allowed_services": ["mcp://calculator", "system://sam.catalog"], "allowed_targets": ["user:system:serviceaccount:sam-nodes:sam-node-sa"]}
],
"bindings": [
{"role": "node-role", "members": ["user:system:serviceaccount:sam-nodes:sam-node-sa"]}
@@ -147,6 +147,13 @@ curl -sf -X POST \
https://CONTROL-PLANE.YOUR-DOMAIN.COM/policies
```
+> **Grant the least privilege that works.** A role's `allowed_services` names the
+> exact backends its members may invoke — list them explicitly rather than using
+> `["*"]`. Be especially careful with the member `sam:system:authenticated`: it
+> matches every identity your OIDC issuer will authenticate, and enrollment is
+> open to any of them, so binding it to a wildcard role gives every tool on every
+> node to anyone who can obtain a token from that issuer.
+
The `sam-mesh` Helm chart runs this as a bootstrap Job for you; see
`charts/sam-mesh/templates/bootstrap-job.yaml`.