Repository navigation
Description
Summary
LocalResource lets the CR author name any object in any namespace via spec.fromResource.fromRef, and the provider fetches it with its own ServiceAccount rather than the author's. The fetched object is serialised in full and committed to a git remote the same author chooses.
The effect is that namespaced create rights on one CRD confer cluster-wide read through the provider's identity, plus an egress path for the result. This is the classic confused-deputy shape.
Filing as hardening, not as a live exploit: this repository is public, private vulnerability reporting is not enabled on it, and there is no SECURITY.md. I have deliberately not included a ready-to-run manifest. Enabling private vulnerability reporting would be worth doing regardless of this issue.
Where
internal/controllers/localresource/localresource.go:352-364— the GVR is built fromspec.fromResource.fromRef.apiVersion+.resource, and when.namespace != ""it is used verbatim. There is no comparison againstcr.GetNamespace()and no kind allow-list.internal/controllers/localresource/localresource.go:365— theGetusese.dynamic, constructed atlocalresource.go:60fromdynamic.NewForConfigOrDie(mgr.GetConfig()). That is the provider's ServiceAccount, never the CR author.helm/git-provider/templates/clusterrole.yaml:8-10— that ServiceAccount holdsapiGroups: ["*"], resources: ["*"], verbs: ["get"]cluster-wide.internal/controllers/localresource/localresource.go:369→internal/tools/localfsWriteK8sResourceserialises the whole unstructured object with no field stripping, soSecret.datais included as-is.- The file is then copied, committed and pushed to
spec.toRepo.url— a URL supplied by the same CR.
No SubjectAccessReview, impersonation, or allow-list exists anywhere in the repo (grep -rn "SubjectAccessReview|Impersonat|AuthorizationV1" returns nothing), and the CRD leaves fromRef.namespace free-form (required: [apiVersion, name, resource]).
Scope, stated fairly
Two things keep this from being a straightforward "anyone can read every Secret":
- It is the ClusterRole's stated intent.
clusterrole.yaml:7carries the comment "ClusterVisibilty, needed to get resource from references across namespaces". Cross-namespace reads are the feature; the gap is that nothing checks whether the author was entitled to the object. - The same class already exists without
fromRef.credentials.secretRef.namespaceis required and free-form,Connectresolves it with the provider's client, and the resulting token is sent to the author-chosentoRepo.url. So "create on this CRD ⇒ reach a Secret the author cannot read" is already true.fromRefwidens the blast radius from git credentials to every object in the cluster.
So the honest framing is: the CRD's trust model is "the author is trusted with the provider's identity" — the standard provider-runtime managed-resource posture — and that model should be made explicit and bounded rather than implicit.
Mitigating in Krateo specifically: the Blueprint Builder / builder-publish publish path only ever emits fromResource.fromString, never fromRef, so this is not reachable from portal-user content today. It needs a direct grant of create localresources.git.krateo.io, which is operator-level.
Options
- Namespace confinement by default — require
fromRef.namespace == cr.Namespaceunless an operator explicitly opts the installation into cross-namespace reads (a flag or a per-namespace allow-list). Preserves the documented use case, removes the default cliff. - Authorize the author —
SubjectAccessReviewthe CR's creator (from the annotation the reconciler records, or via impersonation) against the referenced GVR before theGetat line 365. Strictly correct, more machinery, and needs a trustworthy author identity. - Narrow the ClusterRole — drop
resources: ["*"]to the kinds this actually needs to read, and excludesecretsunless explicitly enabled. Cheapest, and independently worthwhile. - Strip on serialise — never write
Secret.data/stringDatainto a committed file. Narrow (only helps Secrets) but a good defence in depth given the destination is a git remote.
1 and 3 together would remove most of the risk without touching the feature.
Related
- fix(localresource): do not render files when there is nothing to substitute #8 — unconditional templating on the same write path (independent).
- LocalResource with authMethod: bearer can never connect — usernameRef resolved before authMethod is read #5 / fix(localresource): do not require a usernameRef for bearer or cookiefile #6 — the bearer/
usernameRefconnect failure. Both that and fix(localresource): do not render files when there is nothing to substitute #8 came from therepoandlocalresourcecontrollers disagreeing about a shared rule; this issue is a third instance of the same underlying pattern, and worth considering when deciding how much these two controllers should continue to diverge.
🤖 Generated with Claude Code
Activity
fix(localresource): confine fromRef to the referencing resource's own…