Security: Harden file and directory permissions for webhook certificates#2420
Security: Harden file and directory permissions for webhook certificates#2420rakshaak29 wants to merge 2 commits intoopenkruise:masterfrom
Conversation
|
[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. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
fec72bd to
fa08c65
Compare
There was a problem hiding this comment.
Pull request overview
Hardens the webhook certificate filesystem writer by reducing overly permissive directory and file modes used when creating/writing certificates.
Changes:
- Reduce certificate directory creation mode from
0777to0750. - Reduce private key file modes from
0666to0600. - Reduce certificate file modes from
0666to0640.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
fa08c65 to
54d88fb
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #2420 +/- ##
==========================================
+ Coverage 48.77% 49.42% +0.64%
==========================================
Files 324 325 +1
Lines 27928 27950 +22
==========================================
+ Hits 13623 13814 +191
+ Misses 12775 12553 -222
- Partials 1530 1583 +53
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
54d88fb to
9952137
Compare
af9fb62 to
491e174
Compare
Resolves TODO comments in pkg/webhook/util/writer/fs.go by tightening overly permissive file and directory permissions for webhook certificates: - Directory: 0777 -> 0750 - Private keys (CAKey, ServerKey): 0666 -> 0600 - Certificates (CACert, ServerCert): 0666 -> 0640 - Wrap underlying error in directory creation failure message Also adds unit tests for prepareToWrite, certToProjectionMap, and FSCertWriter to improve test coverage. Fixes Ginkgo version mismatch in CI by pinning Ginkgo CLI to v2.27.5 in the Makefile to match the go.mod version. Signed-off-by: rakshaak <rakshaak29@gmail.com> Signed-off-by: rakshaak29 <rakshaak29@gmail.com>
491e174 to
0e5e23b
Compare
Signed-off-by: rakshaak29 <rakshaak29@gmail.com>
Ⅰ. Describe what this PR does
This PR hardens the security of the webhook certificate writer by reducing overly permissive file and directory permissions in
pkg/webhook/util/writer/fs.go. It also addressesTODOcomments left by developers regarding whether the permissions could be reduced.Changes made:
0777(world-writable) to0750.CAKey,ServerKey,ServerKey2) from0666(world-readable/writable) to0600.CACert,ServerCert,ServerCert2) from0666to0640.Ⅱ. Does this pull request fix one issue?
NONE
(Note: If you ended up creating an issue with the previous template, replace
NONEwithfixes #<YOUR_ISSUE_NUMBER>)Ⅲ. Describe how to verify it
go test ./pkg/webhook/util/writer/...