🪢 Open source agent evals & observability: Trace, evaluate, and improve LLM applications with one open platform.
TypeScript analyticsautogenevaluationlangchainlarge-language-modelsllama-indexllmllm-evaluationllm-observabilityllmopsmonitoringobservabilityopen-sourceopenaiplaygroundprompt-engineeringprompt-managementself-hostedycombinator
fix: webhook validation ip leak (#10223)
Max Deichmannc909f50224ee
diff --git a/packages/shared/src/server/webhooks/validation.ts b/packages/shared/src/server/webhooks/validation.tsindex a4243b9901..9b3ec9d0ea 100644--- a/packages/shared/src/server/webhooks/validation.ts+++ b/packages/shared/src/server/webhooks/validation.ts@@ -2,6 +2,7 @@ import dns from "node:dns/promises";import { URL } from "node:url";import { isIPBlocked, isIPAddress, isHostnameBlocked } from "./ipBlocking";import { env } from "../../env";+import { logger } from "../logger";export async function resolveHost(hostname: string): Promise<string[]> {// Returns every A + AAAA address@@ -88,7 +89,12 @@ export async function validateWebhookURL(// Step 4: Check for IP address literals in hostnameif (isIPAddress(hostname)) {if (isIPBlocked(hostname, whitelist.ips, whitelist.ip_ranges)) {- throw new Error(`Blocked IP address detected: ${hostname}`);+ // Log detailed error internally for debugging+ logger.warn(+ `Webhook validation blocked IP address in hostname: ${hostname}`,+ );+ // Throw generic error to user to prevent IP leakage+ throw new Error("Blocked IP address detected");}}@@ -96,7 +102,12 @@ export async function validateWebhookURL(const ips = await resolveHost(hostname);for (const ip of ips) {if (isIPBlocked(ip, whitelist.ips, whitelist.ip_ranges)) {- throw new Error(`Blocked IP address detected: ${ip}`);+ // Log detailed error internally for debugging+ logger.warn(+ `Webhook validation blocked resolved IP address: ${ip} for hostname: ${hostname}`,+ );+ // Throw generic error to user to prevent IP leakage+ throw new Error("Blocked IP address detected");}}}diff --git a/worker/src/__tests__/webhook-validation.test.ts b/worker/src/__tests__/webhook-validation.test.tsindex 86038143bd..d5ccb0cab9 100644--- a/worker/src/__tests__/webhook-validation.test.ts+++ b/worker/src/__tests__/webhook-validation.test.ts@@ -55,6 +55,7 @@ describe("Webhook URL Validation", () => {await expect(validateWebhookURL("http://test.localhost/hook"),).rejects.toThrow("Blocked hostname detected");+ // Generic error message without IP addressawait expect(validateWebhookURL("https://127.0.0.1/hook"),).rejects.toThrow("Blocked IP address detected");@@ -64,6 +65,7 @@ describe("Webhook URL Validation", () => {});it("should reject private network URLs", async () => {+ // Generic error messages without exposing IP addressesawait expect(validateWebhookURL("http://192.168.1.1/hook"),).rejects.toThrow("Blocked IP address detected");@@ -82,18 +84,21 @@ describe("Webhook URL Validation", () => {});it("should reject multicast addresses", async () => {+ // Generic error message without exposing IP addressawait expect(validateWebhookURL("http://224.0.0.1/hook")).rejects.toThrow("Blocked IP address detected",);});it("should reject broadcast addresses", async () => {+ // Generic error message without exposing IP addressawait expect(validateWebhookURL("http://255.255.255.255/hook"),).rejects.toThrow("Blocked IP address detected");});it("should reject IPv6 private addresses", async () => {+ // Generic error messages without exposing IP addressesawait expect(validateWebhookURL("http://[fc00::1]/hook")).rejects.toThrow(/Blocked IP address detected|ipaddr:/,);