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
Make DNS url be IP only
Carlos Monastyrski7740a59dd411
diff --git a/backend/src/lib/api-docs/constants.ts b/backend/src/lib/api-docs/constants.tsindex cad0984945..70baca38b0 100644--- a/backend/src/lib/api-docs/constants.ts+++ b/backend/src/lib/api-docs/constants.ts@@ -2441,7 +2441,7 @@ export const CertificateAuthorities = {hostedZoneId: `The hosted zone ID for the ACME Certificate Authority.`,eabKid: `The External Account Binding (EAB) Key ID for the ACME Certificate Authority. Required if the ACME provider uses EAB.`,eabHmacKey: `The External Account Binding (EAB) HMAC key for the ACME Certificate Authority. Required if the ACME provider uses EAB.`,- dnsResolver: `An optional custom DNS resolver IP address or hostname to use for verifying DNS propagation during ACME challenges. When not set, the system default DNS resolver is used.`+ dnsResolver: `An optional custom DNS resolver IP address to use for verifying DNS propagation during ACME challenges. Must be a valid IP address (e.g. 8.8.8.8). When not set, the system default DNS resolver is used.`},AWS_PCA: {appConnectionId: `The ID of the AWS App Connection to use for authenticating with AWS Private Certificate Authority (PCA). This connection must have permissions to issue, get, and revoke certificates from the specified PCA.`,diff --git a/backend/src/services/certificate-authority/acme/acme-certificate-authority-fns.ts b/backend/src/services/certificate-authority/acme/acme-certificate-authority-fns.tsindex 82f39b711c..05047274ee 100644--- a/backend/src/services/certificate-authority/acme/acme-certificate-authority-fns.ts+++ b/backend/src/services/certificate-authority/acme/acme-certificate-authority-fns.ts@@ -56,34 +56,17 @@ import { cloudflareDeleteTxtRecord, cloudflareInsertTxtRecord } from "./dns-provimport { dnsMadeEasyDeleteTxtRecord, dnsMadeEasyInsertTxtRecord } from "./dns-providers/dns-made-easy";import { route53DeleteTxtRecord, route53InsertTxtRecord } from "./dns-providers/route54";-const validateDnsResolver = async (resolver: string): Promise<void> => {+const validateDnsResolver = (resolver: string): void => {const appCfg = getConfig();if (appCfg.isDevelopmentMode) return;- if (net.isIP(resolver)) {- if (isPrivateIp(resolver) && !appCfg.ALLOW_INTERNAL_IP_CONNECTIONS) {- throw new BadRequestError({ message: "Private/internal IP addresses are not allowed as DNS resolvers" });- }- return;- }-- // Must be a valid hostname format- const HOSTNAME_REGEX = new RE2("^[a-zA-Z0-9.-]+$");- if (!HOSTNAME_REGEX.test(resolver)) {- throw new BadRequestError({ message: `Invalid DNS resolver address: ${resolver}` });+ if (!net.isIP(resolver)) {+ throw new BadRequestError({ message: "DNS resolver must be a valid IP address, not a hostname" });}- try {- const resolvedIps = await dns.promises.resolve4(resolver);- if (resolvedIps.some((ip) => isPrivateIp(ip)) && !appCfg.ALLOW_INTERNAL_IP_CONNECTIONS) {- throw new BadRequestError({ message: "DNS resolver resolves to a private/internal IP address" });- }- } catch (e) {- if (e instanceof BadRequestError) throw e;- throw new BadRequestError({- message: `DNS resolver "${resolver}" could not be resolved. Please provide a valid IP address or resolvable hostname.`- });+ if (isPrivateIp(resolver) && !appCfg.ALLOW_INTERNAL_IP_CONNECTIONS) {+ throw new BadRequestError({ message: "Private/internal IP addresses are not allowed as DNS resolvers" });}};@@ -257,8 +240,7 @@ const waitForDnsPropagation = async (const resolver = new dns.promises.Resolver();if (dnsResolver) {- const resolverIp = net.isIP(dnsResolver) ? dnsResolver : (await dns.promises.resolve4(dnsResolver))[0];- resolver.setServers([resolverIp]);+ resolver.setServers([dnsResolver]);}while (attempts < DNS_PROPAGATION_MAX_RETRIES) {@@ -694,7 +676,7 @@ export const AcmeCertificateAuthorityFns = ({}if (dnsResolver) {- await validateDnsResolver(dnsResolver);+ validateDnsResolver(dnsResolver);}// validates permission to connect@@ -808,7 +790,7 @@ export const AcmeCertificateAuthorityFns = ({}if (dnsResolver) {- await validateDnsResolver(dnsResolver);+ validateDnsResolver(dnsResolver);}const ca = await certificateAuthorityDAL.findById(id);diff --git a/backend/src/services/certificate-authority/acme/acme-certificate-authority-schemas.ts b/backend/src/services/certificate-authority/acme/acme-certificate-authority-schemas.tsindex 9fbb0a7f24..b0305fb543 100644--- a/backend/src/services/certificate-authority/acme/acme-certificate-authority-schemas.ts+++ b/backend/src/services/certificate-authority/acme/acme-certificate-authority-schemas.ts@@ -21,7 +21,7 @@ export const AcmeCertificateAuthorityConfigurationSchema = z.object({accountEmail: z.string().trim().min(1).describe(CertificateAuthorities.CONFIGURATIONS.ACME.accountEmail),eabKid: z.string().trim().max(64).optional().describe(CertificateAuthorities.CONFIGURATIONS.ACME.eabKid),eabHmacKey: z.string().trim().max(512).optional().describe(CertificateAuthorities.CONFIGURATIONS.ACME.eabHmacKey),- dnsResolver: z.string().trim().max(255).optional().describe(CertificateAuthorities.CONFIGURATIONS.ACME.dnsResolver)+ dnsResolver: z.string().trim().ip().optional().describe(CertificateAuthorities.CONFIGURATIONS.ACME.dnsResolver)});export const AcmeCertificateAuthorityCredentialsSchema = z.object({diff --git a/frontend/src/pages/cert-manager/CertificateAuthoritiesPage/components/ExternalCaModal.tsx b/frontend/src/pages/cert-manager/CertificateAuthoritiesPage/components/ExternalCaModal.tsxindex a25f068dc9..0595322368 100644--- a/frontend/src/pages/cert-manager/CertificateAuthoritiesPage/components/ExternalCaModal.tsx+++ b/frontend/src/pages/cert-manager/CertificateAuthoritiesPage/components/ExternalCaModal.tsx@@ -84,7 +84,11 @@ const acmeConfigurationSchema = zaccountEmail: z.string(),eabKid: z.string().optional(),eabHmacKey: z.string().optional(),- dnsResolver: z.string().optional()+ dnsResolver: z+ .string()+ .ip({ message: "Must be a valid IP address" })+ .or(z.literal(""))+ .optional()}).superRefine((data, ctx) => {if (REQUIRED_EAB_DIRECTORIES.includes(data.directoryUrl)) {@@ -728,11 +732,11 @@ export const ExternalCaModal = ({ popUp, handlePopUpToggle }: Props) => {name="configuration.dnsResolver"render={({ field, fieldState: { error } }) => (<FormControl- label="DNS Resolver"+ label="DNS Resolver IP"isError={Boolean(error)}errorText={error?.message}isOptional- tooltipText="A custom DNS resolver IP or hostname used to verify DNS propagation during ACME challenges. Leave empty to use the system default."+ tooltipText="A custom DNS resolver IP address used to verify DNS propagation during ACME challenges. Must be a valid IP (e.g. 8.8.8.8). Leave empty to use the system default."><Input {...field} placeholder="8.8.8.8" /></FormControl>