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): clear NULL extended key usage elements on certificates
Clauded20e1cc840f2
diff --git a/backend/src/db/migrations/20260831165247_certificates-remove-null-extended-key-usages.ts b/backend/src/db/migrations/20260831165247_certificates-remove-null-extended-key-usages.tsnew file mode 100644index 0000000000..38abc1094d--- /dev/null+++ b/backend/src/db/migrations/20260831165247_certificates-remove-null-extended-key-usages.ts@@ -0,0 +1,17 @@+import { Knex } from "knex";++import { TableName } from "../schemas";++export async function up(knex: Knex): Promise<void> {+ if (await knex.schema.hasColumn(TableName.Certificate, "extendedKeyUsages")) {+ await knex(TableName.Certificate)+ .whereRaw(`array_position("extendedKeyUsages", NULL::text) IS NOT NULL`)+ .update({+ extendedKeyUsages: knex.raw(`array_remove("extendedKeyUsages", NULL::text)`)+ });+ }+}++export async function down(): Promise<void> {+ // The removed elements carried no value, so there is nothing to restore.+}diff --git a/backend/src/services/certificate/certificate-fns.test.ts b/backend/src/services/certificate/certificate-fns.test.tsindex cd5301f463..0e862998f3 100644--- a/backend/src/services/certificate/certificate-fns.test.ts+++ b/backend/src/services/certificate/certificate-fns.test.ts@@ -108,4 +108,14 @@ describe("parseCertificateBody usages", () => {expect(fields).not.toHaveProperty("extendedKeyUsages");expect(fields.isCA).toBe(false);});++ test("drops extended key usage OIDs it cannot map rather than leaving holes in the array", async () => {+ const pem = await buildCert([+ new x509.ExtendedKeyUsageExtension(["1.3.6.1.5.5.7.3.1", "1.3.6.1.4.1.311.20.2.2", "1.3.6.1.5.5.7.3.17"], false)+ ]);++ const fields = extractCertificateFields(pem);++ expect(fields.extendedKeyUsages).toEqual(["serverAuth"]);+ });});