Skip to content

armgit / Pulse

Public Imported from GitHub
0

Real-time monitoring dashboard for Proxmox VE, PBS, Docker, Kubernetes, TrueNAS and vSphere. Self-hosted, with alerts for failed backups, full disks, unhealthy containers and offline nodes.

Security fixes: Prevent Apprise RCE and Webhook DNS Rebinding

rcourtman81f146dcf039
diff --git a/internal/notifications/notifications.go b/internal/notifications/notifications.go
index 1e3c5bd039..e75aabe0c2 100644
--- a/internal/notifications/notifications.go
+++ b/internal/notifications/notifications.go
@@ -57,33 +57,73 @@ const (
// createSecureWebhookClient creates an HTTP client with security controls
func (n *NotificationManager) createSecureWebhookClient(timeout time.Duration) *http.Client {
- return &http.Client{
- Timeout: timeout,
- CheckRedirect: func(req *http.Request, via []*http.Request) error {
- // Limit number of redirects to prevent redirect loops
- if len(via) >= WebhookMaxRedirects {
- return fmt.Errorf("stopped after %d redirects", WebhookMaxRedirects)
+ // dedicated transport that pins DNS resolution to prevent rebinding
+ transport := &http.Transport{
+ Proxy: http.ProxyFromEnvironment,
+ DialContext: func(ctx context.Context, network, addr string) (net.Conn, error) {
+ // Extract hostname and port
+ host, port, err := net.SplitHostPort(addr)
+ if err != nil {
+ return nil, err
}
- newURL := req.URL.String()
+ // Validate IP if it's already an IP
+ if ip := net.ParseIP(host); ip != nil {
+ if isPrivateIP(ip) && !n.isIPInAllowlist(ip) {
+ return nil, fmt.Errorf("blocked private IP: %s", ip)
+ }
+ // It's an IP, dial directly
+ d := net.Dialer{Timeout: 10 * time.Second}
+ return d.DialContext(ctx, network, addr)
+ }
- // Prevent redirects to localhost or private networks (SSRF protection)
- if err := n.ValidateWebhookURL(newURL); err != nil {
- log.Warn().
- Str("original", via[0].URL.String()).
- Str("redirect", newURL).
- Err(err).
- Msg("Blocked webhook redirect to unsafe URL")
- return fmt.Errorf("redirect to unsafe URL blocked: %w", err)
+ // Resolve hostname
+ ips, err := net.LookupIP(host)
+ if err != nil {
+ return nil, err
}
- log.Debug().
- Str("from", via[len(via)-1].URL.String()).
- Str("to", newURL).
- Int("redirectCount", len(via)).
- Msg("Following webhook redirect")
+ // Find first permitted IP
+ var permittedIP net.IP
+ for _, ip := range ips {
+ if !isPrivateIP(ip) || n.isIPInAllowlist(ip) {
+ permittedIP = ip
+ break
+ }
+ }
- return nil
+ if permittedIP == nil {
+ return nil, fmt.Errorf("hostname %s resolves to blocked private IPs", host)
+ }
+
+ // Log if we filtered some IPs
+ if len(ips) > 1 {
+ log.Debug().
+ Str("host", host).
+ Str("selected_ip", permittedIP.String()).
+ Msg("DNS resolution pinned for webhook security")
+ }
+
+ // Dial the permitted IP
+ d := net.Dialer{Timeout: 10 * time.Second}
+ return d.DialContext(ctx, network, net.JoinHostPort(permittedIP.String(), port))
+ },
+ ForceAttemptHTTP2: true,
+ MaxIdleConns: 100,
+ IdleConnTimeout: 90 * time.Second,
+ TLSHandshakeTimeout: 10 * time.Second,
+ ExpectContinueTimeout: 1 * time.Second,
+ }
+
+ return &http.Client{
+ Timeout: timeout,
+ Transport: transport,
+ CheckRedirect: func(req *http.Request, via []*http.Request) error {
+ if len(via) >= 10 {
+ return fmt.Errorf("stopped after 10 redirects")
+ }
+ // Re-validate strictly on redirect
+ return n.ValidateWebhookURL(req.URL.String())
},
}
}
@@ -213,7 +253,7 @@ func NormalizeAppriseConfig(cfg AppriseConfig) AppriseConfig {
normalized.Mode = AppriseModeCLI
}
- normalized.CLIPath = strings.TrimSpace(normalized.CLIPath)
+ normalized.CLIPath = "apprise" // Force default binary for security
if normalized.CLIPath == "" {
normalized.CLIPath = "apprise"
}