Skip to content

[backport v0.10 - rancher v2.14] reject user operations on rancher-managed resource quota and limit range resources - #1797#1797 - #1798

Open
andreas-kupries wants to merge 79 commits into
mainfrom
extended-quota-enforcement-2.14
Open

[backport v0.10 - rancher v2.14] reject user operations on rancher-managed resource quota and limit range resources - #1797#1797#1798
andreas-kupries wants to merge 79 commits into
mainfrom
extended-quota-enforcement-2.14

Conversation

@andreas-kupries

Copy link
Copy Markdown
Contributor

Issue:

rancher/rancher#56774

Companion PR r/rancher rancher/rancher#56804

Problem

The NRQR (Rancher-managed namespace ResourceQuota, identified by label resourcequota.management.cattle.io/default-resource-quota: true) was enforced only at namespace creation time. Any user with RBAC access to resourcequotas could subsequently edit the object directly, fully bypassing project-level enforcement.

The same is true for the LimitRange resource managed by Rancher.

Solution

Added validating webhooks for ResourceQuota and LimitRange objects.
The companion PR modifies Rancher to send its requests using the webhook bypass.
This means that the new validators see only user initiated requests, and only have to reject operations involving the marker label. IOW

  • Reject attempts to create resources bearing the marker label
  • Reject attempts to delete resources bearing the marker label
  • Reject attempts to change resources bearing the marker label
    • This includes changes attempting to strip the marker (demotion to unmanaged)
  • Reject attempts to add a marker to to un-marked resources (i.e. prevent promotion to managed)

joshmeranda and others added 30 commits March 25, 2026 14:31
* go get github.com/rancher/wrangler/v3@v3.5.0

* go mod tidy

---------

Co-authored-by: joshmeranda <joshua.meranda@gmail.com>
Co-authored-by: renovate-rancher[bot] <119870437+renovate-rancher[bot]@users.noreply.github.com>
This PR bumps the cluster-api module to v1.12.2, and updates all usage of the v1beta1 API to v1beta2
- Pin base images to SHA256 in Dockerfile
- Replace curl|sh golangci-lint install with verified tarball download
- Replace curl|bash k3d install with pinned v5.8.3 + checksum verification
Co-authored-by: renovate-rancher[bot] <119870437+renovate-rancher[bot]@users.noreply.github.com>
Co-authored-by: renovate-rancher[bot] <119870437+renovate-rancher[bot]@users.noreply.github.com>
Co-authored-by: renovate-rancher[bot] <119870437+renovate-rancher[bot]@users.noreply.github.com>
Co-authored-by: renovate-rancher[bot] <119870437+renovate-rancher[bot]@users.noreply.github.com>
)

Co-authored-by: renovate-rancher[bot] <119870437+renovate-rancher[bot]@users.noreply.github.com>
)

Co-authored-by: renovate-rancher[bot] <119870437+renovate-rancher[bot]@users.noreply.github.com>
Co-authored-by: renovate-rancher[bot] <119870437+renovate-rancher[bot]@users.noreply.github.com>
…1391)

Co-authored-by: renovate-rancher[bot] <119870437+renovate-rancher[bot]@users.noreply.github.com>
Bumped:
- github.com/rancher/wrangler/v3 to v3.5.1
- github.com/rancher/dynamiclistener to v0.8.1
Co-authored-by: rancher-pr-and-push-webhook[bot] <181785884+rancher-pr-and-push-webhook[bot]@users.noreply.github.com>
Co-authored-by: rancher-pr-and-push-webhook[bot] <181785884+rancher-pr-and-push-webhook[bot]@users.noreply.github.com>
#1434)

Backport of the workflow architecture used on main:

- Cut release (.github/workflows/cut-release.yaml) is the workflow_dispatch
  entry point. It validates the version against VERSION.md (read from the
  default branch), creates and pushes the annotated tag, then dispatches
  the On release workflow at the new tag ref via
  `gh workflow run release.yaml --ref <tag>`.

- On release (.github/workflows/release.yaml) is workflow_dispatch with a
  guard job that fails if the dispatched ref is not a tag. Builds for
  amd64 and arm64, creates the GitHub release with binaries + sha256sums
  + Helm chart, and runs publish-image.

The publish-image action's cosign provenance check requires the publish
to run from refs/tags/v*; dispatching On release at the new tag ref
satisfies this. A push:tags trigger does not work because GitHub blocks
workflow runs triggered by GITHUB_TOKEN from starting other runs via
push events; workflow_dispatch is exempt.
Co-authored-by: Chad Roberts <chad.roberts@suse.com>
Co-authored-by: renovate-rancher[bot] <119870437+renovate-rancher[bot]@users.noreply.github.com>
Co-authored-by: renovate-rancher[bot] <119870437+renovate-rancher[bot]@users.noreply.github.com>
Bumps github.com/rancher/wrangler/v3 from v3.5.1 to v3.6.0
for Kubernetes v1.35 support in Rancher v2.14.2.
* Bump dynamiclistener

* Bump norman
Co-authored-by: renovate-rancher[bot] <119870437+renovate-rancher[bot]@users.noreply.github.com>
Co-authored-by: rancher-pr-and-push-webhook[bot] <181785884+rancher-pr-and-push-webhook[bot]@users.noreply.github.com>
renovate-rancher Bot and others added 24 commits June 29, 2026 06:43
Co-authored-by: renovate-rancher[bot] <119870437+renovate-rancher[bot]@users.noreply.github.com>
Co-authored-by: renovate-rancher[bot] <119870437+renovate-rancher[bot]@users.noreply.github.com>
Co-authored-by: rancher-pr-and-push-webhook[bot] <181785884+rancher-pr-and-push-webhook[bot]@users.noreply.github.com>
Co-authored-by: renovate-rancher[bot] <119870437+renovate-rancher[bot]@users.noreply.github.com>
Co-authored-by: renovate-rancher[bot] <119870437+renovate-rancher[bot]@users.noreply.github.com>
Compare versions with golang.org/x/mod/semver and only sync a dep
forward when rancher's version is strictly newer. Skip (no PR) when
webhook is already ahead. Falls back to the previous sync-to-rancher
behavior when a version string isn't valid semver.
Co-authored-by: renovate-rancher[bot] <119870437+renovate-rancher[bot]@users.noreply.github.com>
Co-authored-by: rancher-pr-and-push-webhook[bot] <181785884+rancher-pr-and-push-webhook[bot]@users.noreply.github.com>
Co-authored-by: rancher-pr-and-push-webhook[bot] <181785884+rancher-pr-and-push-webhook[bot]@users.noreply.github.com>
Co-authored-by: rancher-pr-and-push-webhook[bot] <181785884+rancher-pr-and-push-webhook[bot]@users.noreply.github.com>
…creates (#1743)

Backport of #1729

* Set the creatorId annotation on dry-run provisioning Cluster creates

The mutating webhook for provisioning Clusters returned early on every
dry-run request, before setting the creatorId annotation. The
validating webhook requires that annotation on dry-run creates, so
every server-side dry-run create was denied while the identical real
create succeeded. For PSACT-configured clusters the validating webhook
also checks the admission-config secret the mutator writes, which
fails the same way on dry-run since the write never happens.

The mutator's early return is replaced with a guard around only the
PSACT secret handling, the one stage with a real side effect. On
dry-run, the object parse, the creatorId annotation, the
dynamic-schema revert, and the JSON patch generation now run as they
do on a real request, so the preview patch matches the eventual apply.
The validating webhook skips only its checks against that
mutator-produced state (the secret and the cluster fields derived from
it) on dry-run; its pure input checks — the kubernetes version floor
and the template's existence — still run, so invalid input is denied
in the preview exactly as it would be on a real request. The patch
changes only the in-flight request object, which a dry-run never
persists, so the webhook's SideEffects: NoneOnDryRun registration
remains accurate.

* Document provisioning Cluster dry-run behavior

The Cluster admission webhooks previously lacked documentation
about their behavior on server-side dry-run requests. The docs
now cover three key areas: the creatorId annotation is set on
dry-run creates; dynamic-schema reverts apply to dry-run updates;
and Pod Security Admission Configuration Template checks run on
dry-run while secret management is skipped. Updated both the
per-resource and aggregate documentation.
Co-authored-by: renovate-rancher[bot] <119870437+renovate-rancher[bot]@users.noreply.github.com>
Co-authored-by: rancher-pr-and-push-webhook[bot] <181785884+rancher-pr-and-push-webhook[bot]@users.noreply.github.com>
Co-authored-by: rancher-pr-and-push-webhook[bot] <181785884+rancher-pr-and-push-webhook[bot]@users.noreply.github.com>
Co-authored-by: rancher-pr-and-push-webhook[bot] <181785884+rancher-pr-and-push-webhook[bot]@users.noreply.github.com>
Co-authored-by: joshmeranda <joshua.meranda@gmail.com>
Co-authored-by: rancher-pr-and-push-webhook[bot] <181785884+rancher-pr-and-push-webhook[bot]@users.noreply.github.com>
….github.com>

boilerplate from copilot still present. unit tests and checks completely rewritten

added validators for resource quota to webhook
added docs, extended webhook codegen

the new validator rejects creation, edition, deletion of rancher managed resources.
the new validator further rejects promotion of unmanaged to managed resource, and vice versa.
the managed resource is recognized by its marker label.

the validator is written with the assumption that rancher requests are tagged
with webhook bypass and therefore do not reach the validator.

unit tests.

all of the above for limit range resources as well.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.