Safeguard
Security Guides•

Who can read pod logs in Kubernetes, and how do you limit it?

In Kubernetes RBAC, pod logs are a separate subresource, pods/log. Granting pods does not grant logs. How to scope log access and review who has it.

Safeguard Security Team
3 min read

Anyone whose role includes get on the pods/log subresource can read container logs. Pod logs are a subresource, written as pods/log in an RBAC rule, so access must be granted on purpose. Scope it to namespaces, review it regularly, and assume logs may hold sensitive data.

How RBAC names logs

The Kubernetes RBAC documentation explains that some APIs involve a subresource, such as the logs for a pod. A request for logs is a GET on the path for the pod, ending in log. In a role, you write the resource and subresource with a slash. To let a subject read pods and their logs:

apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
  namespace: default
  name: pod-and-pod-logs-reader
rules:
- apiGroups: [""]
  resources: ["pods", "pods/log"]
  verbs: ["get", "list"]

The documentation also notes you can use resourceNames with the pods/exec subresource, which tells you exec is controlled the same way. Remember that logs and exec are separate permissions and exec is far more powerful than reading.

Why log access deserves review

Logs often contain request URLs, user identifiers and, when something goes wrong, tokens or connection strings. A role that reads logs across every namespace is effectively read access to whatever the applications print. See who should have access to production logs.

GrantMeaningTypical holder
get on pods onlySee pod objects, not logsDashboards, many developers
get on pods and pods/logRead logsService owners, on call
create on pods/execRun commands in a containerFew people, break glass
Cluster wide log readRead every namespacePlatform team, audited

Steps to review log access

  1. List roles and cluster roles whose rules include pods/log, or a wildcard on resources. Wildcards grant logs too.
  2. List the bindings for each, and who or what is bound: users, groups, service accounts.
  3. Replace cluster wide grants with namespace roles where possible.
  4. Check service accounts. A CI job or a monitoring agent with cluster log read is a common over-grant.
  5. Move routine reading to a central log store with its own access controls, so people do not need direct cluster access. See should containers log to stdout or files.
  6. Turn on audit logging for the API server so reads of sensitive subresources are recorded. See Kubernetes audit logging policy starter.
  7. Repeat the review every quarter and after team changes.

Common mistakes

Granting a broad built-in role for convenience, then forgetting it. Binding a group that has grown. Treating logs as harmless because they are read only. Reading is how data leaves.

Quick check

Does read access to pods include logs?

No. Logs are the pods/log subresource and need their own entry in a rule.

Can I restrict exec by pod name?

The RBAC documentation says you can use resourceNames with the pods/exec subresource.

Safeguard scans container images and dependencies and keeps a record of policy decisions. Try a free scan at gold.safeguard.sh/scan.

Sources

Last reviewed: 19 October 2026.

Never miss an update

Weekly insights on software supply chain security, delivered to your inbox.

Self-healing security runs on Safeguard.

Your first fix PR is minutes away.

No sales call required, even your agent can complete the purchase over MCP.