Repository navigation
Fix nil pointer dereference in certificateRequestIdentity.Validate - #9081
zanarellidev wants to merge 1 commit into
Conversation
request.RequestResource is optional on the AdmissionRequest API and can be nil, for example when an AdmissionReview is posted directly to the webhook without populating requestResource. Validate dereferenced it unconditionally, causing a panic instead of a clean validation error. Fixes cert-manager#9064 Signed-off-by: zanarelli <[email protected]>
|
[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 |
|
Hi @zanarellidev. Thanks for your PR. I'm waiting for a cert-manager member to verify that this patch is reasonable to test. If it is, they should reply with Regular contributors should join the org to skip this step. Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. 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. |
430a1a9 to
3886271
Compare
|
Friendly ping: still waiting on |
lunarwhite
left a comment
There was a problem hiding this comment.
@zanarellidev really appreciate your work on this.
A small process note for future contributions: #9064 was already assigned which indicating work was in progress (days before you raised #9086). It's generally good practice to check the assignee / comments before starting a fix, to avoid duplicated effort :) No harm done here this time.
I've opened #9086 with a slightly different approach: instead of guarding against nil RequestResource, it switches the plugins to route on Resource/SubResource. The reason I prefer that direction:
Resourceis the always-populated, webhook-facing GVR;RequestResourceis optional and only relevant for Equivalent-match conversion.- A nil guard that returns early or errors still breaks Certificate admission (skips validation or surfaces an internal error on legitimate traffic).
- Routing on
Resourcealso handles version skew under conversion correctly.
|
Good point, I should have checked the issue assignee first. Closing in favor of #9086 which addresses the root cause more thoroughly. |
Pull Request Motivation
Fixes #9064.
request.RequestResourceis optional on theAdmissionRequestAPI and can be nil, for example when anAdmissionReviewis posted directly to the webhook without populatingrequestResource.certificateRequestIdentity.Validatedereferenced it unconditionally, causing a nil pointer panic instead of returning a clean validation error.Added a regression test (
TestValidate_NilRequestResource) that reproduces the panic before the fix and passes after it. Ran the fullinternal/webhook/...andpkg/webhook/...test suites with no regressions.This same unguarded pattern also exists in a few other admission webhook functions in the codebase (
Mutatein the same file, plus two other files) — left out of this PR to keep it scoped to exactly what #9064 reports; happy to follow up separately if useful.AI-assisted (Claude) for investigation and implementation, reviewed by me before submission.
Kind
/kind bug
Release Note