Skip to content

Conversation

@luohoufu
Copy link
Contributor

No description provided.

Copilot AI review requested due to automatic review settings January 14, 2026 09:33
@silenceqi silenceqi merged commit 800b8eb into main Jan 14, 2026
7 checks passed
@silenceqi silenceqi deleted the fix_https_webhook branch January 14, 2026 09:34
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request introduces TLS certificate verification bypass for the webhook event recorder by hardcoding InsecureSkipVerify: true in the HTTP client's TLS configuration. While this may resolve immediate connectivity issues with self-signed certificates, it creates a significant security vulnerability.

Changes:

  • Added crypto/tls import to support TLS configuration
  • Created a custom HTTP transport with TLS certificate verification disabled
  • Applied the custom transport to the HTTP client used for webhook requests

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 126 to +129
func NewWebhookEventRecorder(webhookURL, eventID, clusterID string) record.EventRecorder {
tr := &http.Transport{
TLSClientConfig: &tls.Config{
InsecureSkipVerify: true,
Copy link

Copilot AI Jan 14, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The function signature needs to be updated to accept a parameter that controls TLS certificate verification behavior. The current implementation hardcodes InsecureSkipVerify to true without allowing callers to specify secure defaults. Consider adding a boolean parameter or a configuration struct to NewWebhookEventRecorder.

Suggested change
func NewWebhookEventRecorder(webhookURL, eventID, clusterID string) record.EventRecorder {
tr := &http.Transport{
TLSClientConfig: &tls.Config{
InsecureSkipVerify: true,
func NewWebhookEventRecorder(webhookURL, eventID, clusterID string, insecureSkipVerify bool) record.EventRecorder {
tr := &http.Transport{
TLSClientConfig: &tls.Config{
InsecureSkipVerify: insecureSkipVerify,

Copilot uses AI. Check for mistakes.
@@ -123,13 +124,19 @@ type WebhookEventRecorder struct {
// It requires a webhookURL, identifiers for the event source (eventID) and cluster (clusterID),
// and an existing recorder (typically from the controller-runtime manager) to wrap.
Copy link

Copilot AI Jan 14, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The function documentation does not mention the TLS certificate verification behavior. The documentation should be updated to explicitly state that TLS certificate verification is disabled for webhook connections, warning users about the security implications of this configuration.

Suggested change
// and an existing recorder (typically from the controller-runtime manager) to wrap.
// and an existing recorder (typically from the controller-runtime manager) to wrap.
//
// Security notice: the internal HTTP client used for webhook delivery is configured with
// TLS certificate verification disabled (tls.Config{InsecureSkipVerify: true}). This means
// server certificates are not validated, which can expose webhook traffic to
// man-in-the-middle attacks. This configuration is intended only for trusted environments
// (for example, when using private CAs or during development). For production use on
// untrusted networks, ensure that webhook endpoints are protected appropriately or update
// the configuration to perform proper TLS certificate verification.

Copilot uses AI. Check for mistakes.
tr := &http.Transport{
TLSClientConfig: &tls.Config{
InsecureSkipVerify: true,
},
Copy link

Copilot AI Jan 14, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The TLS configuration is incomplete. When InsecureSkipVerify is set to true, it's a best practice to at least configure other security-related settings on the Transport such as MaxIdleConns, IdleConnTimeout, and TLSHandshakeTimeout to prevent resource exhaustion and improve overall security posture.

Suggested change
},
},
MaxIdleConns: 100,
IdleConnTimeout: 90 * time.Second,
TLSHandshakeTimeout: 10 * time.Second,

Copilot uses AI. Check for mistakes.
Comment on lines +127 to +131
tr := &http.Transport{
TLSClientConfig: &tls.Config{
InsecureSkipVerify: true,
},
}
Copy link

Copilot AI Jan 14, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Setting InsecureSkipVerify to true unconditionally disables TLS certificate verification for all webhook connections. This creates a significant security vulnerability as it makes the application susceptible to man-in-the-middle attacks where an attacker could intercept and potentially modify the event data being sent to the webhook endpoint.

This setting should be configurable rather than hardcoded. Consider adding a parameter to the NewWebhookEventRecorder function or using an environment variable to allow users to control this behavior. This is especially important in production environments where proper certificate validation should be enforced.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants