-
Notifications
You must be signed in to change notification settings - Fork 4
fix(github-config): constrain team management #2718
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
devantler
merged 13 commits into
main
from
codex/propose-fix-for-github-team-management-vulnerability
Aug 18, 2026
Merged
Changes from 2 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
c8a6040
fix(github-config): constrain team management
devantler 6b5eee9
Merge branch 'main' into codex/propose-fix-for-github-team-management…
devantler 73032ca
Merge branch 'main' into codex/propose-fix-for-github-team-management…
devantler 2b57d41
fix(cluster-policies): make the GitHub team guard match, and bind tea…
devantler e1bd002
fix(cluster-policies): scope the external-name rule with match operat…
devantler 5186097
fix(cluster-policies): close the initProvider bypass; drop the extern…
devantler 426766d
fix(cluster-policies): allow-list team repository permissions
devantler 011e8b4
Merge remote-tracking branch 'origin/main' into codex/propose-fix-for…
devantler 07a5343
fix(cluster-policies): require teamIdRef resolve Always instead of de…
devantler fcd8058
fix(cluster-policies): allow-list the teams that exist, not a team th…
devantler e70024a
fix(cluster-policies): bind the repository privilege ceiling to the team
devantler f8311b5
fix(cluster-policies): resolve the ceiling rule's team through initPr…
devantler c8c206b
docs(tests): describe the per-team ceiling accurately in fixture comm…
devantler File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
99 changes: 99 additions & 0 deletions
99
...bases/infrastructure/cluster-policies/best-practices/restrict-github-team-management.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,99 @@ | ||
| # Constrains the high-impact GitHub team managed resources delegated to the | ||
| # github-config tenant. The tenant's Flux Kustomization applies a separately | ||
| # published OCI artifact as the github-config ServiceAccount, and those | ||
| # Crossplane resources reconcile with an org-admin GitHub App. Namespace RBAC can | ||
| # limit the API group, but it cannot restrict resource spec fields such as the | ||
| # team, member, repository, role, or permission. This admission guard keeps that | ||
| # delegation scoped to the intended CODEOWNERS teams and blocks direct numeric | ||
| # team IDs/selectors that would bypass the allow-list enforced through | ||
| # Crossplane references. | ||
| apiVersion: kyverno.io/v1 | ||
| kind: ClusterPolicy | ||
| metadata: | ||
| name: restrict-github-team-management | ||
| annotations: | ||
| policies.kyverno.io/title: Restrict GitHub Team Management | ||
| policies.kyverno.io/category: Security, GitHub | ||
| policies.kyverno.io/severity: high | ||
| policies.kyverno.io/subject: Team, TeamMembership, TeamRepository | ||
| policies.kyverno.io/minversion: 1.6.0 | ||
| policies.kyverno.io/description: >- | ||
| Restricts provider-upjet-github team resources in the github-config | ||
| namespace to the platform CODEOWNERS teams, requires TeamMembership and | ||
| TeamRepository resources to reference those Team objects by name, and | ||
| blocks repository admin grants. This prevents a compromised or unintended | ||
| github-config artifact from adding arbitrary users to arbitrary GitHub | ||
| teams or granting privileged repository access. | ||
| spec: | ||
| validationFailureAction: Enforce | ||
| background: true | ||
| rules: | ||
| - name: teams-allow-listed | ||
| match: | ||
| any: | ||
| - resources: | ||
| kinds: | ||
| - Team.team.github.m.upbound.io | ||
| namespaces: | ||
| - github-config | ||
| validate: | ||
| message: GitHub Team resources managed by github-config must be one of platform or maintainers. | ||
| deny: | ||
| conditions: | ||
| all: | ||
| - key: "{{ request.object.metadata.name }}" | ||
|
devantler marked this conversation as resolved.
devantler marked this conversation as resolved.
|
||
| operator: AnyNotIn | ||
| value: | ||
| - platform | ||
| - maintainers | ||
| - name: teammemberships-reference-allow-listed-teams | ||
| match: | ||
| any: | ||
| - resources: | ||
| kinds: | ||
| - TeamMembership.team.github.m.upbound.io | ||
| namespaces: | ||
| - github-config | ||
| validate: | ||
| message: GitHub TeamMembership resources must use spec.forProvider.teamIdRef.name set to platform or maintainers; direct teamId values and selectors are not allowed. | ||
| deny: | ||
| conditions: | ||
| any: | ||
| - key: "{{ request.object.spec.forProvider.teamId || '' }}" | ||
| operator: NotEquals | ||
| value: "" | ||
|
devantler marked this conversation as resolved.
Outdated
|
||
| - key: "{{ request.object.spec.forProvider.teamIdSelector || `{}` }}" | ||
| operator: NotEquals | ||
| value: {} | ||
| - key: "{{ request.object.spec.forProvider.teamIdRef.name || '' }}" | ||
| operator: AnyNotIn | ||
| value: | ||
| - platform | ||
| - maintainers | ||
|
devantler marked this conversation as resolved.
|
||
| - name: teamrepositories-reference-allow-listed-teams | ||
| match: | ||
| any: | ||
| - resources: | ||
| kinds: | ||
| - TeamRepository.team.github.m.upbound.io | ||
| namespaces: | ||
| - github-config | ||
| validate: | ||
| message: GitHub TeamRepository resources must reference platform or maintainers by spec.forProvider.teamIdRef.name and may not grant admin permission. | ||
| deny: | ||
| conditions: | ||
| any: | ||
| - key: "{{ request.object.spec.forProvider.teamId || '' }}" | ||
| operator: NotEquals | ||
| value: "" | ||
| - key: "{{ request.object.spec.forProvider.teamIdSelector || `{}` }}" | ||
| operator: NotEquals | ||
| value: {} | ||
| - key: "{{ request.object.spec.forProvider.teamIdRef.name || '' }}" | ||
| operator: AnyNotIn | ||
| value: | ||
| - platform | ||
| - maintainers | ||
| - key: "{{ request.object.spec.forProvider.permission || '' }}" | ||
|
devantler marked this conversation as resolved.
|
||
| operator: Equals | ||
| value: admin | ||
|
coderabbitai[bot] marked this conversation as resolved.
Outdated
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.