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
feature: add general env var for allowing internal ip connections and update relevant docs
Scott Wilson499ff3635bc2
diff --git a/backend/src/ee/services/dynamic-secret/dynamic-secret-fns.ts b/backend/src/ee/services/dynamic-secret/dynamic-secret-fns.tsindex 4bd384bcf6..05d4922401 100644--- a/backend/src/ee/services/dynamic-secret/dynamic-secret-fns.ts+++ b/backend/src/ee/services/dynamic-secret/dynamic-secret-fns.ts@@ -42,7 +42,7 @@ export const verifyHostInputValidity = async (host: string, isGateway = false) =inputHostIps.push(...resolvedIps);}- if (!isGateway && !appCfg.DYNAMIC_SECRET_ALLOW_INTERNAL_IP) {+ if (!isGateway && !(appCfg.DYNAMIC_SECRET_ALLOW_INTERNAL_IP || appCfg.ALLOW_INTERNAL_IP_CONNECTIONS)) {const isInternalIp = inputHostIps.some((el) => isPrivateIp(el));if (isInternalIp) throw new BadRequestError({ message: "Invalid db host" });}diff --git a/backend/src/lib/config/env.ts b/backend/src/lib/config/env.tsindex 10ab16b979..907884433a 100644--- a/backend/src/lib/config/env.ts+++ b/backend/src/lib/config/env.ts@@ -197,6 +197,7 @@ const envSchema = z/* ----------------------------------------------------------------------------- *//* App Connections ----------------------------------------------------------------------------- */+ ALLOW_INTERNAL_IP_CONNECTIONS: zodStrBool.default("false"),// awsINF_APP_CONNECTION_AWS_ACCESS_KEY_ID: zpStr(z.string().optional()),diff --git a/backend/src/lib/validator/validate-url.ts b/backend/src/lib/validator/validate-url.tsindex 6feab90362..fdf99e4057 100644--- a/backend/src/lib/validator/validate-url.ts+++ b/backend/src/lib/validator/validate-url.ts@@ -2,10 +2,16 @@ import dns from "node:dns/promises";import { isIPv4 } from "net";+import { getConfig } from "@app/lib/config/env";+import { BadRequestError } from "../errors";import { isPrivateIp } from "../ip/ipRange";export const blockLocalAndPrivateIpAddresses = async (url: string) => {+ const appCfg = getConfig();++ if (appCfg.isDevelopmentMode) return;+const validUrl = new URL(url);const inputHostIps: string[] = [];if (isIPv4(validUrl.host)) {@@ -18,7 +24,8 @@ export const blockLocalAndPrivateIpAddresses = async (url: string) => {inputHostIps.push(...resolvedIps);}const isInternalIp = inputHostIps.some((el) => isPrivateIp(el));- if (isInternalIp) throw new BadRequestError({ message: "Local IPs not allowed as URL" });+ if (isInternalIp && !appCfg.ALLOW_INTERNAL_IP_CONNECTIONS)+ throw new BadRequestError({ message: "Local IPs not allowed as URL" });};type FQDNOptions = {diff --git a/docs/integrations/app-connections/mssql.mdx b/docs/integrations/app-connections/mssql.mdxindex 45082103bc..7e940804d8 100644--- a/docs/integrations/app-connections/mssql.mdx+++ b/docs/integrations/app-connections/mssql.mdx@@ -51,6 +51,10 @@ Infisical supports connecting to Microsoft SQL Server using database principals.- `username` - The username of the login created in the steps above- `password` - The password of the login created in the steps above- `sslCertificate` (optional) - The SSL certificate required for connection (if configured)++ <Note>+ If you are self-hosting Infisical and intend to connect to an internal/private IP address, be sure to set the `ALLOW_INTERNAL_IP_CONNECTIONS` environment variable to `true`.+ </Note></Step></Steps>diff --git a/docs/integrations/app-connections/postgres.mdx b/docs/integrations/app-connections/postgres.mdxindex 523fc35a87..860e9ee3c5 100644--- a/docs/integrations/app-connections/postgres.mdx+++ b/docs/integrations/app-connections/postgres.mdx@@ -41,6 +41,10 @@ Infisical supports connecting to PostgreSQL using a database role.- `username` - The role name of the login created in the steps above- `password` - The role password of the login created in the steps above- `sslCertificate` (optional) - The SSL certificate required for connection (if configured)++ <Note>+ If you are self-hosting Infisical and intend to connect to an internal/private IP address, be sure to set the `ALLOW_INTERNAL_IP_CONNECTIONS` environment variable to `true`.+ </Note></Step></Steps>diff --git a/docs/self-hosting/configuration/envars.mdx b/docs/self-hosting/configuration/envars.mdxindex 8eda21eddf..103c6400e4 100644--- a/docs/self-hosting/configuration/envars.mdx+++ b/docs/self-hosting/configuration/envars.mdx@@ -34,6 +34,10 @@ Used to configure platform-specific security and operational settingsthis to `false`.</ParamField>+<ParamField query="ALLOW_INTERNAL_IP_CONNECTIONS" type="bool" default="false" optional>+ Determines whether App Connections and Dynamic Secrets are permitted to connect with internal/private IP addresses.+</ParamField>+## CORSCross-Origin Resource Sharing (CORS) is a security feature that allows web applications running on one domain to access resources from another domain.