-
Notifications
You must be signed in to change notification settings - Fork 1.1k
fix(security): SA mount restriction #5379
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
base: master
Are you sure you want to change the base?
Conversation
Restrict service account permission in manger config
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Summary of ChangesHello @Pikabooboo, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request implements a crucial security fix by modifying the manager's configuration to prevent the automatic mounting of service account tokens. This action directly mitigates a potential security vulnerability related to unauthorized access or misuse of service account credentials, enhancing the overall security posture of the system. Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request aims to enhance security by disabling the automatic mounting of Service Account tokens in the manager's pod configuration. While this is a valid security hardening technique, in this case, it will prevent the controller manager from accessing the Kubernetes API, which is essential for its operation (e.g., for leader election). This would cause the controller to fail. My review includes a critical comment to remove this change to ensure the controller remains functional. A more robust solution that balances security and functionality would involve more significant changes and could be tackled in a future pull request.
| cpu: 100m | ||
| memory: 20Mi | ||
| terminationGracePeriodSeconds: 10 | ||
| automountServiceAccountToken: false |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Setting automountServiceAccountToken: false will break the controller-manager as it needs to communicate with the Kubernetes API server for tasks like leader election. The kube-rbac-proxy sidecar also needs API access. Without a service account token, both will fail.
To resolve this critical issue, I recommend removing this line. This will restore the default behavior and allow the controller to function correctly.
While disabling automount is a good security practice, it requires explicitly mounting the token for containers that need it. This is a more involved change that can be addressed separately. For now, the safest option is to revert this line.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #5379 +/- ##
=======================================
Coverage 57.56% 57.56%
=======================================
Files 447 447
Lines 31013 31013
=======================================
Hits 17854 17854
Misses 11545 11545
Partials 1614 1614 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
| cpu: 100m | ||
| memory: 20Mi | ||
| terminationGracePeriodSeconds: 10 | ||
| automountServiceAccountToken: false |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please disable automountServiceAccountToken specifically for sample yaml, not the controller yaml.



Restrict service account permission in manger config
Ⅰ. Describe what this PR does
Security issue over SA mounting
Ⅱ. Does this pull request fix one issue?
NONE
Ⅲ. List the added test cases (unit test/integration test) if any, please explain if no tests are needed.
Ⅳ. Describe how to verify it
Run the test setup to see if there still remain code scanning alerts.
Ⅴ. Special notes for reviews