viirya commented on code in PR #998:
URL: 
https://github.com/apache/spark-kubernetes-operator/pull/998#discussion_r4571265078


##########
SECURITY.md:
##########
@@ -12,6 +12,25 @@ This repository extend K8s resource manager to manage Apache 
Spark applications
 
 Automated security scanning agents should consult that document for the 
project's in-scope / out-of-scope declarations before reporting issues.
 
+## Trust assumptions
+
+Users who can create or update `SparkApplication` or `SparkCluster` resources 
are trusted within the
+RBAC scope that the cluster administrator grants to the operator. The operator 
acts on their behalf

Review Comment:
   With the default ClusterRole, this reads as "CR authors are trusted 
cluster-wide", which is broader than the code intends. The submission workers 
and `OwnerResourceDecorator` pin created resources to the CR's namespace. Since 
scanners treat this file as the list of non-findings, could we state it as: 
creating a `SparkApplication`/`SparkCluster` is equivalent to creating pods 
(any image, pod template and service account) in the CR's namespace, the 
operator keeps what it creates in that namespace, and namespace-scoped RBAC is 
defense in depth?



##########
SECURITY.md:
##########
@@ -12,6 +12,25 @@ This repository extend K8s resource manager to manage Apache 
Spark applications
 
 Automated security scanning agents should consult that document for the 
project's in-scope / out-of-scope declarations before reporting issues.
 
+## Trust assumptions
+
+Users who can create or update `SparkApplication` or `SparkCluster` resources 
are trusted within the
+RBAC scope that the cluster administrator grants to the operator. The operator 
acts on their behalf
+with its own service account, not with the permissions of the user who created 
the resource.
+
+By default, the Helm chart grants the operator cluster-wide permissions
+(`operatorRbac.clusterRole.create: true` and 
`operatorRbac.clusterRoleBinding.create: true`).
+Restricting `spark.kubernetes.operator.watchedNamespaces` limits which custom 
resources the operator
+reconciles. It does not limit where the operator's service account may act.
+
+Therefore, a single operator instance is not a tenant isolation boundary 
between the namespaces it
+watches. For tenant isolation, run one operator instance per tenant and grant 
it namespace-scoped
+permissions only: enable `operatorRbac.role.create` and 
`operatorRbac.roleBinding.create`, disable
+`operatorRbac.clusterRole.create` and 
`operatorRbac.clusterRoleBinding.create`, and list only that
+tenant's workload namespaces in `workloadResources.namespaces.data`. See

Review Comment:
   Two cases where this recipe doesn't work as-is:
   - `operatorRbac.kueue.enabled` still needs cluster-scoped read access to 
`resourceflavors`.
   - With `replicas > 1`, the leader-election lease is in the operator 
namespace, but the `leases` rule is only rendered into workload-namespace Roles.
   
   Worth a sentence each.



##########
SECURITY.md:
##########
@@ -12,6 +12,25 @@ This repository extend K8s resource manager to manage Apache 
Spark applications
 
 Automated security scanning agents should consult that document for the 
project's in-scope / out-of-scope declarations before reporting issues.
 
+## Trust assumptions
+
+Users who can create or update `SparkApplication` or `SparkCluster` resources 
are trusted within the
+RBAC scope that the cluster administrator grants to the operator. The operator 
acts on their behalf
+with its own service account, not with the permissions of the user who created 
the resource.
+
+By default, the Helm chart grants the operator cluster-wide permissions
+(`operatorRbac.clusterRole.create: true` and 
`operatorRbac.clusterRoleBinding.create: true`).
+Restricting `spark.kubernetes.operator.watchedNamespaces` limits which custom 
resources the operator
+reconciles. It does not limit where the operator's service account may act.
+
+Therefore, a single operator instance is not a tenant isolation boundary 
between the namespaces it
+watches. For tenant isolation, run one operator instance per tenant and grant 
it namespace-scoped
+permissions only: enable `operatorRbac.role.create` and 
`operatorRbac.roleBinding.create`, disable
+`operatorRbac.clusterRole.create` and 
`operatorRbac.clusterRoleBinding.create`, and list only that
+tenant's workload namespaces in `workloadResources.namespaces.data`. See
+[docs/architecture.md](docs/architecture.md) and 
[docs/operations.md](docs/operations.md) for
+running multiple operator instances on the same cluster.

Review Comment:
   `docs/architecture.md` L90-92 still says per-tenant instances only need 
distinct ClusterRole names, which now contradicts this section. Could we update 
that sentence here?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to