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(pki): reject blank export passwords and drop them for pem
bernie-gc76615f63e90
diff --git a/backend/src/services/pki-sync/linux-server/linux-server-pki-sync-schemas.test.ts b/backend/src/services/pki-sync/linux-server/linux-server-pki-sync-schemas.test.tsindex 3237fe3053..4ce080ee60 100644--- a/backend/src/services/pki-sync/linux-server/linux-server-pki-sync-schemas.test.ts+++ b/backend/src/services/pki-sync/linux-server/linux-server-pki-sync-schemas.test.ts@@ -144,8 +144,8 @@ describe("Linux Server export password validation", () => {expect(parseCreate("jks").success).toBe(false);});- test("ignores a leftover password for PEM", () => {- expect(parseCreate("pem", " ").success).toBe(true);+ test("rejects a blank password for PEM too", () => {+ expect(parseCreate("pem", " ").success).toBe(false);});test("keeps surrounding spaces in a real password", () => {diff --git a/backend/src/services/pki-sync/pki-sync-schemas.ts b/backend/src/services/pki-sync/pki-sync-schemas.tsindex 0897676a02..491803739b 100644--- a/backend/src/services/pki-sync/pki-sync-schemas.ts+++ b/backend/src/services/pki-sync/pki-sync-schemas.ts@@ -6,6 +6,7 @@ import { HOSTNAME_MAX_LENGTH, isValidHostname } from "@app/lib/validator/validatimport { buildCertificateNameSchemaTestName } from "./pki-sync-certificate-name-fns";import { PkiSync, PkiSyncStatus } from "./pki-sync-enums";+import { EXPORT_PASSWORD_BLANK_MESSAGE } from "./pki-sync-export-fns";import { PKI_SYNC_MAX_FILTER_ORDERS } from "./pki-sync-filter-fns";import { HOST_COMMAND_MAX_LENGTH } from "./pki-sync-host-command-fns";@@ -31,7 +32,11 @@ export const KeystoreAliasSchema = z"Alias of the private key entry in a PKCS#12 or JKS keystore. Defaults to the certificate's file base name. JKS stores aliases in lowercase.");-export const ExportPasswordSchema = z.string().min(1).max(1024);+export const ExportPasswordSchema = z+ .string()+ .min(1)+ .max(1024)+ .refine((password) => password.trim().length > 0, { message: EXPORT_PASSWORD_BLANK_MESSAGE });export const IncludeTruststoreSchema = z.boolean()diff --git a/frontend/src/components/pki-syncs/forms/schemas/pki-sync-schema.ts b/frontend/src/components/pki-syncs/forms/schemas/pki-sync-schema.tsindex f866b670a4..2558cf20c5 100644--- a/frontend/src/components/pki-syncs/forms/schemas/pki-sync-schema.ts+++ b/frontend/src/components/pki-syncs/forms/schemas/pki-sync-schema.ts@@ -174,7 +174,11 @@ const refineKeystoreAlias = (};// Drops keystore options the chosen format does not use, since the API rejects them.-export const removeUnusedKeystoreOptions = <T extends { syncOptions?: unknown }>(data: T): T => {+export const removeUnusedKeystoreOptions = <+ T extends { syncOptions?: unknown; credentials?: unknown }+>(+ data: T+): T => {if (!data.syncOptions) return data;const syncOptions = { ...(data.syncOptions as Record<string, unknown>) };const alias =@@ -183,6 +187,8 @@ export const removeUnusedKeystoreOptions = <T extends { syncOptions?: unknown }>if (!isKeystoreExportFormat(exportFormat) || !alias) delete syncOptions.keystoreAlias;else syncOptions.keystoreAlias = alias;if (exportFormat !== PkiSyncExportFormat.Jks) delete syncOptions.includeTruststore;+ if (!isKeystoreExportFormat(exportFormat))+ return { ...data, syncOptions, credentials: undefined };return { ...data, syncOptions };};