Skip to content

Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.

Update validate-url.ts

Daniel Hougaard27b5e4661a01
diff --git a/backend/src/lib/validator/validate-url.ts b/backend/src/lib/validator/validate-url.ts
index 3bdfbeb2e0..1720d04775 100644
--- a/backend/src/lib/validator/validate-url.ts
+++ b/backend/src/lib/validator/validate-url.ts
@@ -28,8 +28,15 @@ export const blockLocalAndPrivateIpAddresses = async (url: string, isGateway = f
if (validUrl.hostname === "localhost" || validUrl.hostname === "host.docker.internal") {
throw new BadRequestError({ message: "Local IPs not allowed as URL" });
}
- const resolvedIps = await dns.resolve4(validUrl.hostname);
- inputHostIps.push(...resolvedIps);
+ try {
+ const resolvedIps = await dns.resolve4(validUrl.hostname);
+ inputHostIps.push(...resolvedIps);
+ } catch (err) {
+ if ((err as { code: string })?.code !== "ENOTFOUND") throw err;
+
+ const resolvedIps = (await dns.lookup(validUrl.hostname, { all: true, family: 4 })).map(({ address }) => address);
+ inputHostIps.push(...resolvedIps);
+ }
}
const isInternalIp = inputHostIps.some((el) => isPrivateIp(el));
if (isInternalIp && !appCfg.ALLOW_INTERNAL_IP_CONNECTIONS)