-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Mounted cloud credentials should not be world-readable #8919
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
Conversation
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.
Error: pkg/install/daemonset.go:183:1: File is not properly formatted (gofmt)
SecretName: "cloud-credentials",
^
Please fix linters.
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #8919 +/- ##
==========================================
- Coverage 60.05% 60.02% -0.04%
==========================================
Files 378 378
Lines 42883 42940 +57
==========================================
+ Hits 25754 25775 +21
- Misses 15582 15615 +33
- Partials 1547 1550 +3 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
b372610
to
de248e8
Compare
The changes LGTM, could you please check the failures in git actions? |
|
@kaovilai Hmm. That doesn't seem like it should be related to my change. I guess I'll update the branch (it's out of date anyway) and see what happens on retest. If it's still failig, I'll dig into it in more detail on Monday. |
e2e tests are all failing with BSL validation failures.
What I don't quite understand is that the only change made by this PR is to update file permissions for the secret to remove the world-read permission. If this caused errors in the e2e Kind cluster, I would expect to see a "permission denied" error originating in velero code, not in the AWS APIs. If we're able to make the AWS call at all, that suggests that velero was able to read the file. If velero was able to read the file, then the AWS API call should be identical with and without this change. |
I think it's still related to the credentials permission. |
@blackpiglet I need to do some extra logging and see what's going on with the actual velero UID/GID and the file permissions. It could be that the kind clusters don't work properly without everything being world-readable here, or it could be that the e2e tests are doing something weird with the uid/gid for velero causing problems. In theory the velero server should have no problems accessing files with read permission for the owner and group, since the owner and group for the file should be the same as for the velero server process. |
4a68116
to
20b4deb
Compare
After adding some logging, it looks like what's happening is that the default credentials, mounted from the secret at |
Thanks for the detailed information. |
@sseago As a result, adding the securityContext section to the Velero deployment and the DaemonSet should fix the issue. The Velero server image, Ubuntu Jammy, uses the user I will create a PR to add the SecurityContext for the Velero install CLI and the E2E tests. |
@blackpiglet ok, so I figured out what was different between the OpenShift cluster and the Kind e2e cluster. So for mounted secrets, there is no way to change the user ownership. It will always be root/0. However, if the pod sets One possible fix is this:
Another option would be to skip the |
@sseago Are there any security hardening rules required to make the secret non-world-readable? If we go the first way, there would be a potential need to modify the fsGroup value when the Velero server image changes. It would be the same if we choose to use a default value. If there is no clear requirement for that, I prefer to go the second way. |
@blackpiglet I wasn't suggesting that we hard-code any fsGroup values but making it an optional parameter. If the user doesn't specify fsGroup, then we don't add the security context, and we can just mount it read-only as 444. If the user supplies fsGroup at install, then we set it in the security context and then the velero server will run with that group set. But we could go with the simpler second approach. @weshayutin do you know whether the OADP request for modifying these permissions was related to any specific security hardening rule, or was it just a general sense that we shouldn't have world-readable secrets? I think the practical impact here is relatively small, since in general, users who aren't authorized to access the credentials shouldn't be able to run processes in the velero pod anyway. |
That should work. |
Signed-off-by: Scott Seago <[email protected]>
@blackpiglet Updated with option 2: default creds mounted 444 (read-only), non-default cred files created 640 (no world-read). |
…8919) Signed-off-by: Scott Seago <[email protected]>
…8919) Signed-off-by: Scott Seago <[email protected]>
…8919) Signed-off-by: Scott Seago <[email protected]>
Thank you for contributing to Velero!
Please add a summary of your change
Cloud credentials (both default and BSL-named) should not be world-readable. This PR makes the file access permissions more restrictive.
Does your change fix a particular issue?
Fixes #8906
Please indicate you've done the following:
make new-changelog
) or comment/kind changelog-not-required
on this PR.site/content/docs/main
.