Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,18 @@ spec:
- name: not-platform-applied
expression: >-
request.userInfo.username != 'system:serviceaccount:flux-system:kustomize-controller'
# The External Secrets controller adds its cleanup finalizer to every
# ExternalSecret and PushSecret it reconciles, an UPDATE under its own
# identity. Without this condition a platform-placed resource that names
# the ClusterSecretStore is admitted on create and then never reconciled,
# because that first metadata update is denied. Only an update that leaves
# `spec` unchanged is skipped, so the controller still cannot change which
# store or key a resource reads, and a tenant cannot act as this identity.
- name: not-controller-metadata-update
expression: >-
!(request.userInfo.username == 'system:serviceaccount:external-secrets:external-secrets' &&
request.operation == 'UPDATE' && oldObject != null &&
object.?spec.orValue({}) == oldObject.?spec.orValue({}))
variables:
- name: kro
expression: "request.userInfo.username == 'system:serviceaccount:kro-system:kro'"
Expand Down
20 changes: 19 additions & 1 deletion scripts/tests/test-restrict-tenant-secret-stores.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,22 @@ if ! grep -Fq "${expected_summary}" "${output_file}"; then
exit 1
fi

echo "Tenant SecretStore policy enforced the expected 5-pass/7-deny boundary."
# The controller carve-out covers only spec-preserving updates. Under the
# controller identity the CLI evaluates each fixture as a create, so the same
# boundary must hold: the controller cannot create a store reference.
controller_user_info="${repo_root}/tests/restrict-tenant-secret-stores/user-info-controller.yaml"
if kyverno apply "${policy}" \
Comment thread
devantler marked this conversation as resolved.
Resolved
--resource "${fixtures}" \
--values-file "${values}" \
--userinfo "${controller_user_info}" \
--remove-color >"${output_file}" 2>&1; then
echo "::error::tenant SecretStore policy admitted every fixture created by the External Secrets controller"
exit 1
fi
if ! grep -Fq "${expected_summary}" "${output_file}"; then
echo "::error::tenant SecretStore policy exempted a create by the External Secrets controller"
sed -n '1,80p' "${output_file}"
exit 1
fi

echo "Tenant SecretStore policy enforced the expected 5-pass/7-deny boundary for tenant and controller creates."
11 changes: 11 additions & 0 deletions tests/restrict-tenant-secret-stores/user-info-controller.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
apiVersion: cli.kyverno.io/v1alpha1
kind: UserInfo
metadata:
name: external-secrets-controller
userInfo:
username: system:serviceaccount:external-secrets:external-secrets
groups:
- system:serviceaccounts
- system:serviceaccounts:external-secrets
- system:authenticated
Loading