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
fix(kmip): bound hostnames/IPs so a long list can't overflow the column
bernie-g8eb952b98881
diff --git a/backend/src/db/migrations/20260605120000_kmip-server-cert-config.ts b/backend/src/db/migrations/20260605120000_kmip-server-cert-config.tsindex c3f791b1d3..411b4f4fcf 100644--- a/backend/src/db/migrations/20260605120000_kmip-server-cert-config.ts+++ b/backend/src/db/migrations/20260605120000_kmip-server-cert-config.ts@@ -7,10 +7,16 @@ import { TableName } from "../schemas";// reads these; the legacy machine-identity /server-registration path still takes them in the body.const COLUMNS = ["hostnamesOrIps", "ttl", "keyAlgorithm"] as const;+// hostnamesOrIps is a comma-separated SAN list, so it gets the same capacity as the issued cert's+// altNames column (4096); ttl/keyAlgorithm are short and use the default varchar length.+const HOSTNAMES_OR_IPS_MAX_LENGTH = 4096;+export async function up(knex: Knex): Promise<void> {if (await knex.schema.hasTable(TableName.KmipServer)) {await knex.schema.alterTable(TableName.KmipServer, (t) => {- COLUMNS.forEach((col) => t.string(col));+ t.string("hostnamesOrIps", HOSTNAMES_OR_IPS_MAX_LENGTH);+ t.string("ttl");+ t.string("keyAlgorithm");});}}diff --git a/backend/src/ee/routes/v1/kmip-server-router.ts b/backend/src/ee/routes/v1/kmip-server-router.tsindex 7c3d825bf1..443f760c5e 100644--- a/backend/src/ee/routes/v1/kmip-server-router.ts+++ b/backend/src/ee/routes/v1/kmip-server-router.ts@@ -32,6 +32,13 @@ const SanitizedKmipServerSchema = KmipServersSchema.pick({// rather than passing it on every launch. ttl/keyAlgorithm get sensible defaults.const ttlField = z.string().refine((val) => ms(val) > 0, "TTL must be a positive number");+// hostnamesOrIps is stored in a varchar(4096) column (matching the issued cert's altNames), so cap+// the resolved SAN list there to surface a clean 400 instead of a DB "value too long" error.+const hostnamesOrIpsField = validateAltNamesField.refine(+ (val) => val.length <= 4096,+ "Hostnames or IPs must be at most 4096 characters"+);+const AwsAuthMethodConfigSchema = z.object({id: z.string().uuid(),stsEndpoint: z.string(),@@ -99,7 +106,7 @@ export const registerKmipServerRouter = async (server: FastifyZodProvider) => {description: "Create a new KMIP server with an initial auth method.",body: z.object({name: slugSchema({ min: 1, max: 32, field: "name" }),- hostnamesOrIps: validateAltNamesField,+ hostnamesOrIps: hostnamesOrIpsField,ttl: ttlField.optional().default("1y"),keyAlgorithm: z.nativeEnum(CertKeyAlgorithm).optional().default(CertKeyAlgorithm.RSA_2048),authMethod: SettableAuthMethodInputSchema@@ -208,7 +215,7 @@ export const registerKmipServerRouter = async (server: FastifyZodProvider) => {schema: {params: z.object({ kmipServerId: z.string().uuid() }),body: z.object({- hostnamesOrIps: validateAltNamesField.optional(),+ hostnamesOrIps: hostnamesOrIpsField.optional(),ttl: ttlField.optional(),keyAlgorithm: z.nativeEnum(CertKeyAlgorithm).optional(),authMethod: SettableAuthMethodInputSchema.optional()diff --git a/frontend/src/pages/organization/KmipServersPage/KmipServerDetailsByIDPage/components/KmipServerCertConfig/KmipServerCertConfigModal.tsx b/frontend/src/pages/organization/KmipServersPage/KmipServerDetailsByIDPage/components/KmipServerCertConfig/KmipServerCertConfigModal.tsxindex 1d6ef9ec81..790d9e71c9 100644--- a/frontend/src/pages/organization/KmipServersPage/KmipServerDetailsByIDPage/components/KmipServerCertConfig/KmipServerCertConfigModal.tsx+++ b/frontend/src/pages/organization/KmipServersPage/KmipServerDetailsByIDPage/components/KmipServerCertConfig/KmipServerCertConfigModal.tsx@@ -34,8 +34,12 @@ const keyAlgorithmOptions = certKeyAlgorithms.map(({ value }) => ({ value, label: certKeyAlgorithmToNameMap[value] }));const schema = z.object({- hostnamesOrIps: z.string().trim().min(1, "At least one hostname or IP is required"),- ttl: z.string().trim().min(1, "TTL is required"),+ hostnamesOrIps: z+ .string()+ .trim()+ .min(1, "At least one hostname or IP is required")+ .max(4096, "Hostnames or IPs must be at most 4096 characters"),+ ttl: z.string().trim().min(1, "TTL is required").max(64, "TTL is too long"),keyAlgorithm: z.nativeEnum(CertKeyAlgorithm)});diff --git a/frontend/src/pages/organization/KmipServersPage/components/components/KmipServerDeployModal.tsx b/frontend/src/pages/organization/KmipServersPage/components/components/KmipServerDeployModal.tsxindex 57b5a80c80..4527fd5c50 100644--- a/frontend/src/pages/organization/KmipServersPage/components/components/KmipServerDeployModal.tsx+++ b/frontend/src/pages/organization/KmipServersPage/components/components/KmipServerDeployModal.tsx@@ -25,8 +25,12 @@ import { useCreateKmipServer } from "@app/hooks/api/kmipServers";const schema = z.object({name: z.string().trim().min(1, "Name is required"),- hostnamesOrIps: z.string().trim().min(1, "At least one hostname or IP is required"),- ttl: z.string().trim().min(1, "TTL is required"),+ hostnamesOrIps: z+ .string()+ .trim()+ .min(1, "At least one hostname or IP is required")+ .max(4096, "Hostnames or IPs must be at most 4096 characters"),+ ttl: z.string().trim().min(1, "TTL is required").max(64, "TTL is too long"),keyAlgorithm: z.nativeEnum(CertKeyAlgorithm)});