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
fips improvements
Daniel Hougaard253c46f21d36
diff --git a/Dockerfile.fips.standalone-infisical b/Dockerfile.fips.standalone-infisicalindex d2b2a2d87d..dec41a36dd 100644--- a/Dockerfile.fips.standalone-infisical+++ b/Dockerfile.fips.standalone-infisical@@ -145,7 +145,11 @@ RUN wget https://www.openssl.org/source/openssl-3.1.2.tar.gz \&& cd openssl-3.1.2 \&& ./Configure enable-fips \&& make \- && make install_fips+ && make install_fips \+ && cd / \+ && rm -rf /openssl-build \+ && apt-get clean \+ && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*# Install Infisical CLIRUN curl -1sLf 'https://artifacts-cli.infisical.com/setup.deb.sh' | bash \@@ -186,7 +190,7 @@ ENV NODE_ENV productionENV STANDALONE_BUILD trueENV STANDALONE_MODE trueENV ChrystokiConfigurationPath=/usr/safenet/lunaclient/-ENV NODE_OPTIONS="--max-old-space-size=1024"+ENV NODE_OPTIONS="--max-old-space-size=8192"# FIPS mode of operation:ENV OPENSSL_CONF=/backend/nodejs.fips.cnfdiff --git a/backend/Dockerfile.dev.fips b/backend/Dockerfile.dev.fipsindex 977362e031..b954ccd50e 100644--- a/backend/Dockerfile.dev.fips+++ b/backend/Dockerfile.dev.fips@@ -59,7 +59,11 @@ RUN wget https://www.openssl.org/source/openssl-3.1.2.tar.gz \&& cd openssl-3.1.2 \&& ./Configure enable-fips \&& make \- && make install_fips+ && make install_fips \+ && cd / \+ && rm -rf /openssl-build \+ && apt-get clean \+ && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*# ? App setupdiff --git a/backend/src/db/migrations/utils/env-config.ts b/backend/src/db/migrations/utils/env-config.tsindex debaea03fc..de32f4db90 100644--- a/backend/src/db/migrations/utils/env-config.ts+++ b/backend/src/db/migrations/utils/env-config.ts@@ -53,7 +53,7 @@ export const getMigrationEnvConfig = async (superAdminDAL: TSuperAdminDALFactorylet envCfg = Object.freeze(parsedEnv.data);- const fipsEnabled = await crypto.initialize(superAdminDAL);+ const fipsEnabled = await crypto.initialize(superAdminDAL, envCfg);// Fix for 128-bit entropy encryption key expansion issue:// In FIPS it is not ideal to expand a 128-bit key into 256-bit. We solved this issue in the past by creating the ROOT_ENCRYPTION_KEY.diff --git a/backend/src/lib/crypto/cryptography/crypto.ts b/backend/src/lib/crypto/cryptography/crypto.tsindex 967e7e0074..b8fc45645a 100644--- a/backend/src/lib/crypto/cryptography/crypto.ts+++ b/backend/src/lib/crypto/cryptography/crypto.ts@@ -14,7 +14,7 @@ import { TSuperAdminDALFactory } from "@app/services/super-admin/super-admin-dalimport { ADMIN_CONFIG_DB_UUID } from "@app/services/super-admin/super-admin-service";import { isBase64 } from "../../base64";-import { getConfig } from "../../config/env";+import { getConfig, TEnvConfig } from "../../config/env";import { CryptographyError } from "../../errors";import { logger } from "../../logger";import { asymmetricFipsValidated } from "./asymmetric-fips";@@ -106,12 +106,12 @@ const cryptographyFactory = () => {}};- const $setFipsModeEnabled = (enabled: boolean) => {+ const $setFipsModeEnabled = (enabled: boolean, envCfg?: Pick<TEnvConfig, "ENCRYPTION_KEY">) => {// If FIPS is enabled, we need to validate that the ENCRYPTION_KEY is in a base64 format, and is a 256-bit key.if (enabled) {crypto.setFips(true);- const appCfg = getConfig();+ const appCfg = envCfg || getConfig();if (appCfg.ENCRYPTION_KEY) {// we need to validate that the ENCRYPTION_KEY is a base64 encoded 256-bit key@@ -141,14 +141,14 @@ const cryptographyFactory = () => {$isInitialized = true;};- const initialize = async (superAdminDAL: TSuperAdminDALFactory) => {+ const initialize = async (superAdminDAL: TSuperAdminDALFactory, envCfg?: Pick<TEnvConfig, "ENCRYPTION_KEY">) => {if ($isInitialized) {return isFipsModeEnabled();}if (process.env.FIPS_ENABLED !== "true") {logger.info("Cryptography module initialized in normal operation mode.");- $setFipsModeEnabled(false);+ $setFipsModeEnabled(false, envCfg);return false;}@@ -158,11 +158,11 @@ const cryptographyFactory = () => {if (serverCfg) {if (serverCfg.fipsEnabled) {logger.info("[FIPS]: Instance is configured for FIPS mode of operation. Continuing startup with FIPS enabled.");- $setFipsModeEnabled(true);+ $setFipsModeEnabled(true, envCfg);return true;}logger.info("[FIPS]: Instance age predates FIPS mode inception date. Continuing without FIPS.");- $setFipsModeEnabled(false);+ $setFipsModeEnabled(false, envCfg);return false;}@@ -171,7 +171,7 @@ const cryptographyFactory = () => {// TODO(daniel): check if it's an enterprise deployment// if there is no server cfg, and FIPS_MODE is `true`, its a fresh FIPS deployment. We need to set the fipsEnabled to true.- $setFipsModeEnabled(true);+ $setFipsModeEnabled(true, envCfg);return true;};