Skip to content

Enforce authz on resourcegraph and renderrawgraph endpoints#425

Open
tamalsaha wants to merge 2 commits into
masterfrom
authz-resourcegraph
Open

Enforce authz on resourcegraph and renderrawgraph endpoints#425
tamalsaha wants to merge 2 commits into
masterfrom
authz-resourcegraph

Conversation

@tamalsaha

Copy link
Copy Markdown
Contributor

Problem

The ResourceGraph (meta.k8s.appscode.com/resourcegraphs) and RenderRawGraph (renderrawgraphs) endpoints built and returned the object graph for an arbitrary, user-supplied source resource without any authorization check on that resource. Unlike the core genericresource, podview, and resourceservice storages — which already perform per-object RBAC checks — these two received no authorizer at all.

Because the graph response includes the names and namespaces of parent/child/related objects discovered cluster-wide, any caller able to reach the endpoint could enumerate cluster topology for resources they otherwise cannot read.

Fix

Gate both endpoints with the same RBAC pattern used elsewhere in the registry:

  • rbacAuthorizer is now passed to both storages in apiserver.go.
  • When a source object is supplied, the caller must have get access to it before the graph is returned.
  • RenderRawGraph also renders the whole-cluster graph when no source is given; that path now requires cluster-wide read access (get on */*, i.e. effectively cluster-admin).

For the UI's normal use the caller is already viewing the source object (so already has get on it), so legitimate requests are unaffected; the change only closes access for resources the caller cannot read.

Notes / scope

This is the first of several authorization fixes identified in a codebase review. It covers the two endpoints with unambiguous "get on the source object" semantics. Other endpoints (scanner/reports, cluster-scope cost/reports and policy/reports) need separate, more careful handling and are intentionally not included here. The render/resourcequery endpoints already enforce authorization via the graph engine's user impersonation, so they are out of scope too.

Testing

  • go build ./... passes.
  • go vet and gofmt clean on the changed files.

The ResourceGraph and RenderRawGraph endpoints returned the object graph
for an arbitrary user-supplied source resource without checking whether the
caller was allowed to read it. The graph response exposes the names and
namespaces of related objects across the cluster, so any user able to call
the endpoint could enumerate cluster topology for resources they otherwise
cannot see.

Gate both endpoints with an RBAC check, mirroring the per-object
authorization already done by the core genericresource/podview storages:

- When a source object is supplied, require "get" access to it before
  returning its graph.
- RenderRawGraph additionally renders the whole-cluster graph when no source
  is given; that path now requires cluster-wide read access (get on */*).

The rbacAuthorizer is now passed to both storages in apiserver.go.

Signed-off-by: Tamal Saha <tamal@appscode.com>
kodiakhq[bot]
kodiakhq Bot previously approved these changes Jun 25, 2026
Add unit tests with a fake authorizer (and a fake client with a static
RESTMapper) asserting:

- resourcegraph: a source-scoped request denies with Forbidden and authorizes
  "get" on the referenced object; missing user info is a BadRequest.
- renderrawgraph: a source-scoped request authorizes "get" on the object,
  while the no-source whole-cluster graph requires cluster-wide read (get */*).

Signed-off-by: Tamal Saha <tamal@appscode.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant