Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.
TypeScript acmeagentsai-agentscertificate-managementdevsecopsenvironment-variableskubernetesopen-sourcepampkipostgresprivate-caprivileged-access-managementsecret-managementsecret-managersecretssecrets-managementsecuritysecurity-toolsvault
add size limit
Thiago Araujo da Silva2e6243560608
diff --git a/backend/src/services/alert/alert-channel-service.test.ts b/backend/src/services/alert/alert-channel-service.test.tsindex 334ced30c2..2432f84f0d 100644--- a/backend/src/services/alert/alert-channel-service.test.ts+++ b/backend/src/services/alert/alert-channel-service.test.ts@@ -249,6 +249,38 @@ describe("alert channel service", () => {expect(stored.headers).toEqual([{ key: "Authorization", value: "Bearer abc" }]);});+ test("counts kept webhook header values toward the combined header length", async () => {+ const { service } = buildService();+ const channel = seedRow({+ id: "ch-1",+ channelType: AlertChannelType.WEBHOOK,+ encryptedConfig: encConfig({+ url: "https://example.com/hook",+ headers: [{ key: "Authorization", value: "a".repeat(4000) }]+ })+ });++ await expect(+ updateChannel(+ service,+ {+ recipientScope: RECIPIENT_SCOPE,+ channelId: "ch-1",+ config: {+ url: "https://example.com/hook",+ headers: [+ { key: "Authorization", value: ALERT_CHANNEL_REDACTED_VALUE },+ { key: "X-Trace", value: "b".repeat(200) }+ ]+ }+ },+ channel as never,+ cipher,+ tx+ )+ ).rejects.toThrow("Webhook header names and values can add up to at most 4096 characters");+ });+test("rejects a redacted webhook header that has no stored value", async () => {const { service } = buildService();const channel = seedRow({diff --git a/backend/src/services/alert/alert-channel-types.ts b/backend/src/services/alert/alert-channel-types.tsindex f6273981a4..925585efb3 100644--- a/backend/src/services/alert/alert-channel-types.ts+++ b/backend/src/services/alert/alert-channel-types.ts@@ -94,6 +94,10 @@ export const EmailChannelConfigSchema = z.object({}).strip();export const WEBHOOK_MAX_HEADERS = 20;+// Keeps the largest valid webhook config (URL, signing secret, headers) under the route's 8192-character+// config cap. It is checked on the merged config, so headers kept as "******" across edits count too.+export const WEBHOOK_MAX_HEADERS_LENGTH = 4096;+const WEBHOOK_RESERVED_HEADERS = ["content-type","x-infisical-signature",@@ -161,6 +165,12 @@ export const WebhookChannelConfigSchema = z.object({},{ message: "Header names must be unique" })+ .refine(+ (headers) =>+ (headers ?? []).reduce((total, header) => total + header.key.length + header.value.length, 0) <=+ WEBHOOK_MAX_HEADERS_LENGTH,+ { message: `Webhook header names and values can add up to at most ${WEBHOOK_MAX_HEADERS_LENGTH} characters` }+ )});export const SlackChannelConfigSchema = z.object({diff --git a/backend/src/services/alert/channels/alert-channels.test.ts b/backend/src/services/alert/channels/alert-channels.test.tsindex 08d0f9b821..b0dafbb31b 100644--- a/backend/src/services/alert/channels/alert-channels.test.ts+++ b/backend/src/services/alert/channels/alert-channels.test.ts@@ -8,6 +8,7 @@ import {DIRECTED_ALERT_CHANNEL_TYPES,SlackChannelConfigSchema,TAlertPayload,+ WEBHOOK_MAX_HEADERS_LENGTH,WebhookChannelConfigSchema} from "../alert-channel-types";import { sendEmailNotification } from "./alert-channel-email-fns";@@ -250,6 +251,20 @@ describe("WebhookChannelConfigSchema headers", () => {expect(result.error?.issues[0].message).toBe("Header names must be unique");});+ test("limits the combined length of header names and values", () => {+ const value = "a".repeat(WEBHOOK_MAX_HEADERS_LENGTH - "Authorization".length);+ expect(withHeaders([{ key: "Authorization", value }]).success).toBe(true);++ const result = withHeaders([+ { key: "Authorization", value },+ { key: "X-Env", value: "prod" }+ ]);+ expect(result.success).toBe(false);+ expect(result.error?.issues[0].message).toBe(+ `Webhook header names and values can add up to at most ${WEBHOOK_MAX_HEADERS_LENGTH} characters`+ );+ });+test("rejects names that are not HTTP tokens", () => {expect(withHeaders([{ key: "X Bad", value: "a" }]).success).toBe(false);});diff --git a/docs/documentation/platform/pki/applications/alerting/webhook-alerts.mdx b/docs/documentation/platform/pki/applications/alerting/webhook-alerts.mdxindex 356a3df715..c29f183c20 100644--- a/docs/documentation/platform/pki/applications/alerting/webhook-alerts.mdx+++ b/docs/documentation/platform/pki/applications/alerting/webhook-alerts.mdx@@ -33,7 +33,7 @@ A webhook channel on a certificate [alert](/documentation/platform/pki/applicatiInfisical sends every custom header you add on the channel with each request. Use them when your endpoint authenticates callers with a header, such as the HTTP source of an incident management tool that expects an `Authorization: Bearer <token>` header.-A channel can have up to 20 headers. Header values are encrypted, and the API returns them as `******` after you save the channel. When you edit the channel, leave a value unchanged to keep it, or enter a new one to replace it.+A channel can have up to 20 headers, and their names and values can add up to 4,096 characters. Header values are encrypted, and the API returns them as `******` after you save the channel. When you edit the channel, leave a value unchanged to keep it, or enter a new one to replace it.You can't set the `Content-Type`, `Content-Length`, `Transfer-Encoding`, `Connection`, `Host`, and `x-infisical-signature` headers, because Infisical sets them on every request.