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
Address PR comments
Carlos Monastyrski84d7010f0ea5
diff --git a/backend/src/services/app-connection/azure-dns/azure-dns-connection-fns.ts b/backend/src/services/app-connection/azure-dns/azure-dns-connection-fns.tsindex 70c374a5da..e8524c6fa5 100644--- a/backend/src/services/app-connection/azure-dns/azure-dns-connection-fns.ts+++ b/backend/src/services/app-connection/azure-dns/azure-dns-connection-fns.ts@@ -1,4 +1,5 @@import { AxiosError } from "axios";+import RE2 from "re2";import { request } from "@app/lib/config/request";import { BadRequestError } from "@app/lib/errors";@@ -8,6 +9,19 @@ import { AppConnection } from "@app/services/app-connection/app-connection-enumsimport { AzureDnsConnectionMethod } from "./azure-dns-connection-enum";import { TAzureDnsConnection, TAzureDnsConnectionConfig, TAzureDnsZone } from "./azure-dns-connection-types";+const AZURE_DNS_ZONE_RESOURCE_ID_REGEX = new RE2(+ "^\\/subscriptions\\/[0-9a-f-]+\\/resourceGroups\\/[^/]+\\/providers\\/Microsoft\\.Network\\/dnsZones\\/[^/]+$",+ "i"+);++export const validateAzureDnsZoneResourceId = (hostedZoneId: string): void => {+ if (!AZURE_DNS_ZONE_RESOURCE_ID_REGEX.test(hostedZoneId)) {+ throw new BadRequestError({+ message: "Invalid Azure DNS Zone resource ID format."+ });+ }+};+interface AzureDnsZonesResponse {value: Array<{id: string;@@ -91,6 +105,10 @@ export const listAzureDnsZones = async (appConnection: TAzureDnsConnection): Probreak;}+ if (!response.nextLink.startsWith("https://management.azure.com/")) {+ throw new BadRequestError({ message: "Invalid nextLink URL from Azure API" });+ }+// eslint-disable-next-line no-await-in-loopresponse = await fetchZones(response.nextLink);}diff --git a/backend/src/services/app-connection/azure-dns/azure-dns-connection-schema.ts b/backend/src/services/app-connection/azure-dns/azure-dns-connection-schema.tsindex bfaae26276..060520c205 100644--- a/backend/src/services/app-connection/azure-dns/azure-dns-connection-schema.ts+++ b/backend/src/services/app-connection/azure-dns/azure-dns-connection-schema.ts@@ -1,3 +1,4 @@+import RE2 from "re2";import z from "zod";import { AppConnections } from "@app/lib/api-docs";@@ -11,19 +12,21 @@ import {import { APP_CONNECTION_NAME_MAP } from "../app-connection-maps";import { AzureDnsConnectionMethod } from "./azure-dns-connection-enum";+const AZURE_GUID_REGEX = new RE2("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$", "i");++const azureGuidSchema = z+ .string()+ .trim()+ .refine((val) => AZURE_GUID_REGEX.test(val), { message: "Invalid GUID format" });export const AzureDnsConnectionClientSecretCredentialsSchema = z.object({- tenantId: z.string().trim().min(1, "Tenant ID required").max(256, "Tenant ID cannot exceed 256 characters"),- clientId: z.string().trim().min(1, "Client ID required").max(256, "Client ID cannot exceed 256 characters"),+ tenantId: azureGuidSchema.describe("Tenant ID must be a valid GUID"),+ clientId: azureGuidSchema.describe("Client ID must be a valid GUID"),clientSecret: z.string().trim().min(1, "Client secret required").max(256, "Client secret cannot exceed 256 characters"),- subscriptionId: z- .string()- .trim()- .min(1, "Subscription ID required")- .max(256, "Subscription ID cannot exceed 256 characters")+ subscriptionId: azureGuidSchema.describe("Subscription ID must be a valid GUID")});const BaseAzureDnsConnectionSchema = BaseAppConnectionSchema.extend({diff --git a/backend/src/services/certificate-authority/acme/dns-providers/azure-dns.ts b/backend/src/services/certificate-authority/acme/dns-providers/azure-dns.tsindex cf91199190..082f2dd8db 100644--- a/backend/src/services/certificate-authority/acme/dns-providers/azure-dns.ts+++ b/backend/src/services/certificate-authority/acme/dns-providers/azure-dns.ts@@ -2,7 +2,10 @@ import axios from "axios";import { request } from "@app/lib/config/request";import { logger } from "@app/lib/logger";-import { getAzureDnsAccessToken } from "@app/services/app-connection/azure-dns/azure-dns-connection-fns";+import {+ getAzureDnsAccessToken,+ validateAzureDnsZoneResourceId+} from "@app/services/app-connection/azure-dns/azure-dns-connection-fns";import { TAzureDnsConnection } from "@app/services/app-connection/azure-dns/azure-dns-connection-types";export const azureDnsInsertTxtRecord = async (@@ -15,6 +18,8 @@ export const azureDnsInsertTxtRecord = async (credentials: { tenantId, clientId, clientSecret }} = connection;+ validateAzureDnsZoneResourceId(hostedZoneId);+logger.info({ hostedZoneId, recordName, value }, "Inserting TXT record for Azure DNS");try {@@ -57,6 +62,8 @@ export const azureDnsDeleteTxtRecord = async (credentials: { tenantId, clientId, clientSecret }} = connection;+ validateAzureDnsZoneResourceId(hostedZoneId);+logger.info({ hostedZoneId, recordName, value }, "Deleting TXT record for Azure DNS");try {