Skip to content

fix(marketplace): connecting a repository installs its components, and Flux installs them as cluster-admin #4978

Closed

Description

@myasnikovdaniil

Summary

For every PackageSource it materializes, tap materializer calls ensureRegistration (tapmaterializer_reconciler.go L181). It creates Package named after the source with default variant and ignores AlreadyExists (L456-L473). Package reconciler then creates HelmRelease for every component of that variant that has install block, not only for charts that back ApplicationDefinitions. So connecting a repository installs charts publisher chose. With scaffold from cozypkg init installed component is <app>-rd with install.namespace: cozy-system (init.go L70-L85), arbitrary Helm chart rendered into cozy-system.

Those HelmReleases run under Flux service account flux, bound to cluster-admin (fluxcd.yaml L7831-L7847). Manifest doesn't set --default-service-account, and internal/operator and pkg/registry/apps never set serviceAccountName on HelmRelease, so there is no impersonation.

privileged is declared by publisher in the same artifact. It is a prompt for admin, doesn't protect against publisher who wants to do harm.

Second effect of the same call: ensureRegistration runs when new revision is materialized, so registration Package that admin removed with cozypkg del is created again on next revision.

Impact

Creating Tap needs cluster admin, tenant roles have only get, list and watch on taps (clusterroles.yaml L47-L52). So this is admin connecting repository they chose, but 1.7 docs say "tapping itself installs nothing", and connect actually runs publisher's charts as cluster-admin with no extra step. Confirmation gate for privileged components exists (#4308), but it is racy (#4359) and doesn't cover later revisions of handed-over Package (#4358).

Read in code, not reproduced on a cluster.

Suggested fix

For a 1.7.x patch:

  • Remove ensureRegistration call, or put it behind its own flag that is off by default. Connecting then only materializes PackageSources, installing is explicit cozypkg add or dashboard action.
  • Consequence to accept: apps from connected repository appear in catalog only after admin adds them. If flag route is chosen, re-creation of deleted Package stays in that mode.

Long term #4359 proposes producing catalog from PackageSource metadata instead of from an install. I think that is the right shape, this issue is the smaller step.

Acceptance

  • Connecting repository creates no Package, HelmRelease or ApplicationDefinition.
  • Package removed with cozypkg del stays removed across new revisions.
  • #4358 and #4359 stay open for long term design.

Activity

  1. added
    kind/bugCategorizes issue or PR as related to a bug
    securitySecurity-related issues and features
    priority/important-soonMust be staffed and worked on either currently, or very soon, ideally in time for the next release
    area/platformIssues or PRs related to platform infrastructure (bundle, flux, talos, installer)
    on Oct 20, 2026
  2. myasnikovdaniil commented on Nov 4, 2026

    @myasnikovdaniil
    ContributorAuthor

    Fixed in #5071, backported to release-1.7 in #5117. PR says "Addresses", so issue was not closed automatically.

    ensureRegistration is removed, connecting now only materializes PackageSources and install is explicit cozypkg add, so Package removed with cozypkg del is not re-created on next revision. Package that 1.7.0 already auto-created on connect stays after upgrade.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/platformIssues or PRs related to platform infrastructure (bundle, flux, talos, installer)kind/bugCategorizes issue or PR as related to a bugpriority/important-soonMust be staffed and worked on either currently, or very soon, ideally in time for the next releasesecuritySecurity-related issues and featurestriage/acceptedIndicates an issue is ready to be actively worked on

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions