NO-JIRA: Fix path traversal vulnerability in certificate file handling - #124
NO-JIRA: Fix path traversal vulnerability in certificate file handling#124tpantelis wants to merge 1 commit into
Conversation
|
Pipeline controller notification For optional jobs, comment This repository is configured in: LGTM mode |
|
Warning Review limit reached
Next review available in: 41 minutes You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Repository: openshift/coderabbit/.coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
WalkthroughThe webhook now validates and normalizes certificate and key paths before TLS setup. Certificate monitoring reuses the validated certificate path. New tests cover path normalization and empty-path rejection. ChangesWebhook TLS path handling
Estimated code review effort: 2 (Simple) | ~10 minutes 🚥 Pre-merge checks | ✅ 14 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (14 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: tpantelis 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 |
|
@tpantelis: This pull request explicitly references no jira issue. DetailsIn response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository. |
There was a problem hiding this comment.
Actionable comments posted: 3
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@cmd/webhook/main.go`:
- Around line 295-318: Reject raw parent-directory path elements before
normalization in the path-validation flow around filepath.Clean, then remove the
final realPath substring check so safe names containing ".." remain valid.
Update cmd/webhook/main.go lines 295-318 accordingly. Change
cmd/webhook/main_test.go lines 410-415 to expect parent-directory input to fail
validation.
- Around line 304-320: The symlink-resolving logic in the path validation
function must not replace the configured path used for TLS reads and reloads.
Use filepath.EvalSymlinks only to validate the resolved target, avoid rejecting
Kubernetes AtomicWriter paths containing "..", and return the cleaned absolute
configured path (absPath) so certificate rotation continues to follow the
symlink. Add coverage for a tls.crt symlink targeting ..data/tls.crt that
verifies both startup and subsequent rotation.
- Around line 102-109: Update the fatal error handling around validateFilePath
for both the certificate and key paths to log only stable validation-failure
messages. Remove the supplied flag values and validation error details from the
glog.Fatalf calls while preserving termination and distinguishing certificate
versus key validation failures.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository: openshift/coderabbit/.coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: 03919ff2-050e-4f25-a6e8-0c6c2bfc7c54
📒 Files selected for processing (2)
cmd/webhook/main.gocmd/webhook/main_test.go
Added validation to sanitize certificate and key file paths from CLI arguments to prevent path traversal attacks. This addresses the Snyk security scan finding that was failing CI checks. Changes: - Add validateFilePath() function to clean and validate file paths - Validate cert/key paths at startup before use - Use validated paths in certificate watching loop - Add comprehensive test coverage for path validation The validation ensures: - Empty paths are rejected - Paths are cleaned to remove . and .. elements - Paths are converted to absolute paths - Symlinks are resolved to real paths - No .. patterns remain after processing Signed-off-by: Tom Pantelis <tompantelis@gmail.com>
fb891d3 to
3197d32
Compare
|
@tpantelis: The following test failed, say
Full PR test history. Your PR dashboard. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here. |
Added validation to sanitize certificate and key file paths from CLI arguments to prevent path traversal attacks. This addresses the Snyk security scan finding that was failing CI checks.
Changes:
The validation ensures:
Summary by CodeRabbit