From b893c3e6905d259e1b5ea391d099c320641f8af8 Mon Sep 17 00:00:00 2001 From: Akhil Mohan Date: Mon, 22 Apr 2024 18:25:45 +0530 Subject: [PATCH] feat(server): removed local ip check for self hosted users in secret rotation --- .../secret-rotation-queue-fn.ts | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/backend/src/ee/services/secret-rotation/secret-rotation-queue/secret-rotation-queue-fn.ts b/backend/src/ee/services/secret-rotation/secret-rotation-queue/secret-rotation-queue-fn.ts index 8eade1626..93f63a685 100644 --- a/backend/src/ee/services/secret-rotation/secret-rotation-queue/secret-rotation-queue-fn.ts +++ b/backend/src/ee/services/secret-rotation/secret-rotation-queue/secret-rotation-queue-fn.ts @@ -90,16 +90,20 @@ export const secretRotationDbFn = async ({ const appCfg = getConfig(); const ssl = ca ? { rejectUnauthorized: false, ca } : undefined; + const isCloud = Boolean(appCfg.LICENSE_SERVER_KEY); // quick and dirty way to check if its cloud or not const dbHost = appCfg.DB_HOST || getDbConnectionHost(appCfg.DB_CONNECTION_URI); + + if ( + isCloud && + // internal ips + (host === "host.docker.internal" || host.match(/^10\.\d+\.\d+\.\d+/) || host.match(/^192\.168\.\d+\.\d+/)) + ) + throw new Error("Invalid db host"); if ( host === "localhost" || host === "127.0.0.1" || // database infisical uses - dbHost === host || - // internal ips - host === "host.docker.internal" || - host.match(/^10\.\d+\.\d+\.\d+/) || - host.match(/^192\.168\.\d+\.\d+/) + dbHost === host ) throw new Error("Invalid db host");