Skip to content

Commit 8076520

Browse files
authored
atecontroller: Limit the Secrets read to the egress MITM CA pool (agent-substrate#3036)
The controller reads one Secret, egress-mitm-ca-pool in ate-system, but its RBAC marker granted get, list and watch on every Secret in the cluster. Add namespace and resourceNames to the marker. The rule moves from the ClusterRole to the ate-system Role, which is already bound. <!-- The PR title becomes the release note. Write it for users. --> Why is this needed? (Or link the issue. Open one first for features, API, install or CI changes.) Fixes part of agent-substrate#2936 <!-- e.g. "AI-assisted, I reviewed and tested it." No AI co-author trailers. --> AI use: I-assisted, I reviewed and tested it. <!-- Breaking change? Describe what users must do on upgrade and ask for the `breaking-change` label. --> - [x] Tests pass - [ ] Docs updated
1 parent 4d98981 commit 8076520

2 files changed

Lines changed: 16 additions & 9 deletions

File tree

‎cmd/atecontroller/internal/controllers/egressmitmtrust_controller.go‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,12 @@ func EgressMITMCAPoolRef(systemNamespace string) types.NamespacedName {
5757
return types.NamespacedName{Namespace: systemNamespace, Name: egressMITMCAPoolSecret}
5858
}
5959

60-
//+kubebuilder:rbac:groups=core,resources=secrets,verbs=get;list;watch
60+
// resourceNames covers list and watch because the manager's cache selects the
61+
// Secret by metadata.name (managerOptions in main.go), which the apiserver
62+
// authorizes as a request for that one name. Without the selector the grant
63+
// would deny them.
64+
//
65+
//+kubebuilder:rbac:groups=core,resources=secrets,resourceNames=egress-mitm-ca-pool,verbs=get;list;watch,namespace=ate-system
6166
//+kubebuilder:rbac:groups=certificates.k8s.io,resources=clustertrustbundles,verbs=get;list;watch;create;update;patch;delete
6267
//+kubebuilder:rbac:groups=certificates.k8s.io,resources=signers,resourceNames=egress-mitm.ate.dev/*,verbs=attest
6368

‎manifests/ate-install/generated/role.yaml‎

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,6 @@ rules:
2727
- get
2828
- list
2929
- watch
30-
- apiGroups:
31-
- ""
32-
resources:
33-
- secrets
34-
verbs:
35-
- get
36-
- list
37-
- watch
3830
- apiGroups:
3931
- ""
4032
resources:
@@ -141,6 +133,16 @@ metadata:
141133
name: ate-controller
142134
namespace: ate-system
143135
rules:
136+
- apiGroups:
137+
- ""
138+
resourceNames:
139+
- egress-mitm-ca-pool
140+
resources:
141+
- secrets
142+
verbs:
143+
- get
144+
- list
145+
- watch
144146
- apiGroups:
145147
- discovery.k8s.io
146148
resources:

0 commit comments

Comments
 (0)