Skip to content
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

fix: Prevent containers from running as root by removing unnecessary anyuid SCC bindings #1460

Merged
merged 5 commits into from
Jan 14, 2025

Conversation

ugiordan
Copy link
Contributor

Description

This PR addresses the security concern of containers running with root privileges by removing the following ServiceAccounts from default RoleBindings granting the anyuid SCC:

  • Notebook
  • ModelMesh
  • ModelController
  • Dashboard

These changes help ensure that containers run with non-root user privileges and comply with security policies. Additionally, this makes the default RoleBinding that assigns the default ServiceAccount to the anyuid SCC unnecessary:

> oc get rolebinding opendatahub -oyaml | yq 'del(.metadata)'
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: ClusterRole
  name: system:openshift:scc:anyuid
subjects:
  - kind: ServiceAccount
    name: default
    namespace: opendatahub

How Has This Been Tested?

Screenshot or short clip

Merge criteria

  • You have read the contributors guide.
  • Commit messages are meaningful - have a clear and concise summary and detailed explanation of what was changed and why.
  • Pull Request contains a description of the solution, a link to the JIRA issue, and to any dependent or related Pull Request.
  • Testing instructions have been added in the PR body (for PRs involving changes that are not immediately obvious).
  • The developer has manually tested the changes and verified that the changes work

@openshift-ci openshift-ci bot requested review from asanzgom and Sara4994 December 18, 2024 15:43
@biswassri
Copy link
Contributor

/test opendatahub-operator-e2e

Copy link

codecov bot commented Dec 20, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 19.88%. Comparing base (8865ea6) to head (8513444).
Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1460      +/-   ##
==========================================
- Coverage   19.90%   19.88%   -0.02%     
==========================================
  Files         161      160       -1     
  Lines       10833    10818      -15     
==========================================
- Hits         2156     2151       -5     
+ Misses       8448     8440       -8     
+ Partials      229      227       -2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@ugiordan
Copy link
Contributor Author

/retest

@@ -62,7 +61,6 @@ func (s *componentHandler) NewComponentReconciler(ctx context.Context, mgr ctrl.
WithAction(initialize).
WithAction(devFlags).
WithAction(configureDependencies).
WithAction(security.NewUpdatePodSecurityRoleBindingAction(serviceAccounts)).
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not following this in the entirety, but for Notebooks we really don't need to have anyuid scc, certainly not after https://issues.redhat.com/browse/RHOAIENG-72 got in, and IMO even before that we were good with any uid.

cc @opendatahub-io/notebook-devs for heads-up!

@ugiordan
Copy link
Contributor Author

/test opendatahub-operator-e2e

@ugiordan ugiordan force-pushed the bug/RHOAIENG-7916 branch 2 times, most recently from a3aa31f to b094cc0 Compare January 13, 2025 11:58
@ugiordan
Copy link
Contributor Author

/uncc @Sara4994
/cc @lburgazzoli

@openshift-ci openshift-ci bot requested review from lburgazzoli and removed request for Sara4994 January 13, 2025 12:01
@@ -91,7 +90,6 @@ func (s *componentHandler) NewComponentReconciler(ctx context.Context, mgr ctrl.
WithAction(initialize).
WithAction(devFlags).
WithAction(configureDependencies).
WithAction(security.NewUpdatePodSecurityRoleBindingAction(serviceAccounts)).
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is NewUpdatePodSecurityRoleBindingAction is not more in use, we can probably remove it

… and the security folder containing both, as they are no longer needed.
@lburgazzoli
Copy link
Contributor

/lgtm

@ugiordan
Copy link
Contributor Author

/retest

@lburgazzoli
Copy link
Contributor

/test opendatahub-operator-e2e

Copy link

openshift-ci bot commented Jan 14, 2025

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: lburgazzoli

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-merge-bot openshift-merge-bot bot merged commit 71f79e2 into opendatahub-io:main Jan 14, 2025
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

5 participants