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
separate image on GHCR for fips toolchain
Thiago Araujo da Silva58b79c785b81
diff --git a/.github/workflows/publish-fips-toolchain.yml b/.github/workflows/publish-fips-toolchain.ymlnew file mode 100644index 0000000000..1f5d074773--- /dev/null+++ b/.github/workflows/publish-fips-toolchain.yml@@ -0,0 +1,108 @@+name: "Publish FIPS test toolchain image"++# Builds backend/Dockerfile.fips-toolchain and publishes it to GHCR so that+# run-backend-tests.yml does not have to compile two OpenSSL trees on every PR.+#+# Tagged with the content hash of the toolchain Dockerfile: run-backend-tests.yml+# computes the same hash and pulls that exact tag, falling back to building from+# source when a PR changes the toolchain and the new tag isn't published yet.+#+# Built on native runners per architecture rather than under QEMU: emulated arm64+# OpenSSL compilation takes hours. arm64 is published because docker-compose.dev.yml+# uses this image for local dev on Apple Silicon.++on:+ push:+ branches:+ - main+ paths:+ - "backend/Dockerfile.fips-toolchain"+ - ".github/workflows/publish-fips-toolchain.yml"+ workflow_dispatch:++concurrency:+ group: publish-fips-toolchain+ cancel-in-progress: false++jobs:+ build:+ name: Build ${{ matrix.arch }}+ runs-on: ${{ matrix.runner }}+ timeout-minutes: 60+ permissions:+ contents: read+ packages: write+ strategy:+ fail-fast: false+ matrix:+ include:+ - arch: amd64+ runner: ubuntu-latest+ - arch: arm64+ runner: ubuntu-24.04-arm+ steps:+ - name: ☁️ Checkout source+ uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2++ - name: Set up Docker Buildx+ uses: docker/setup-buildx-action@8d2750c68a42422c14e847fe6c8ac0403b4cbd6f # v3.12.0++ - name: Log in to GHCR+ uses: docker/login-action@c94ce9fb468520275223c153574b00df6fe4bcc9 # v3.7.0+ with:+ registry: ghcr.io+ username: ${{ github.actor }}+ password: ${{ secrets.GITHUB_TOKEN }}++ - name: Compute image ref and tag+ id: meta+ run: |+ set -euo pipefail+ OWNER=$(echo "${{ github.repository_owner }}" | tr '[:upper:]' '[:lower:]')+ echo "image=ghcr.io/${OWNER}/backend-fips-toolchain" >> "$GITHUB_OUTPUT"+ echo "tag=${{ hashFiles('backend/Dockerfile.fips-toolchain') }}" >> "$GITHUB_OUTPUT"++ - name: Build and push ${{ matrix.arch }}+ uses: docker/build-push-action@10e90e3645eae34f1e60eeb005ba3a3d33f178e8 # v6.19.2+ with:+ context: backend+ file: backend/Dockerfile.fips-toolchain+ push: true+ platforms: linux/${{ matrix.arch }}+ tags: ${{ steps.meta.outputs.image }}:${{ steps.meta.outputs.tag }}-${{ matrix.arch }}++ manifest:+ name: Merge manifest+ runs-on: ubuntu-latest+ needs: build+ timeout-minutes: 15+ permissions:+ contents: read+ packages: write+ steps:+ - name: ☁️ Checkout source+ uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2++ - name: Set up Docker Buildx+ uses: docker/setup-buildx-action@8d2750c68a42422c14e847fe6c8ac0403b4cbd6f # v3.12.0++ - name: Log in to GHCR+ uses: docker/login-action@c94ce9fb468520275223c153574b00df6fe4bcc9 # v3.7.0+ with:+ registry: ghcr.io+ username: ${{ github.actor }}+ password: ${{ secrets.GITHUB_TOKEN }}++ - name: Create multi-arch manifests+ run: |+ set -euo pipefail+ OWNER=$(echo "${{ github.repository_owner }}" | tr '[:upper:]' '[:lower:]')+ IMAGE="ghcr.io/${OWNER}/backend-fips-toolchain"+ TAG="${{ hashFiles('backend/Dockerfile.fips-toolchain') }}"+ for target in "$TAG" main; do+ docker buildx imagetools create \+ -t "${IMAGE}:${target}" \+ "${IMAGE}:${TAG}-amd64" \+ "${IMAGE}:${TAG}-arm64"+ done+ docker buildx imagetools inspect "${IMAGE}:${TAG}"diff --git a/.github/workflows/run-backend-tests.yml b/.github/workflows/run-backend-tests.ymlindex 799379a6ef..2feec37386 100644--- a/.github/workflows/run-backend-tests.yml+++ b/.github/workflows/run-backend-tests.yml@@ -10,11 +10,18 @@ on:- "backend/.eslintrc.js"workflow_call:+concurrency:+ group: run-backend-tests-${{ github.event.pull_request.number || github.ref }}+ cancel-in-progress: ${{ github.event_name == 'pull_request' }}+jobs:check-be-pr:name: Run integration testruns-on: ubuntu-latesttimeout-minutes: 45+ permissions:+ contents: read+ packages: readsteps:- name: Free up disk spaceuses: jlumbroso/free-disk-space@54081f138730dfa15788a46383842cd2f914a1be # v1.3.1@@ -23,7 +30,7 @@ jobs:android: truedotnet: truehaskell: true- large-packages: true+ large-packages: falseswap-storage: truedocker-images: true@@ -52,12 +59,38 @@ jobs:- name: Start postgres and redisrun: touch .env && docker compose -f docker-compose.dev.yml up -d db redis- name: Start Secret Rotation testing databases- run: docker compose -f docker-compose.e2e-dbs.yml up -d --wait --wait-timeout 300+ run: docker compose -f docker-compose.e2e-dbs.yml up -d- name: Run unit testrun: npm run test:unitworking-directory: backend- name: Set up Docker Buildxuses: docker/setup-buildx-action@8d2750c68a42422c14e847fe6c8ac0403b4cbd6f # v3.12.0+ - name: Log in to GHCR+ continue-on-error: true+ uses: docker/login-action@c94ce9fb468520275223c153574b00df6fe4bcc9 # v3.7.0+ with:+ registry: ghcr.io+ username: ${{ github.actor }}+ password: ${{ secrets.GITHUB_TOKEN }}+ - name: Resolve FIPS toolchain image+ id: toolchain+ run: |+ set -euo pipefail+ # Lowercased: GHCR rejects uppercase repository names and the owner is "Infisical".+ OWNER=$(echo "${{ github.repository_owner }}" | tr '[:upper:]' '[:lower:]')+ IMAGE="ghcr.io/${OWNER}/backend-fips-toolchain"+ TAG="${{ hashFiles('backend/Dockerfile.fips-toolchain') }}"+ if docker pull --quiet "$IMAGE:$TAG"; then+ echo "Using published toolchain $IMAGE:$TAG"+ echo "image=$IMAGE:$TAG" >> "$GITHUB_OUTPUT"+ else+ echo "::notice::No published toolchain for $TAG (this PR changes backend/Dockerfile.fips-toolchain); building from source."+ docker buildx build --load \+ -f backend/Dockerfile.fips-toolchain \+ -t "backend-fips-toolchain:$TAG" \+ backend+ echo "image=backend-fips-toolchain:$TAG" >> "$GITHUB_OUTPUT"+ fi- name: Build FIPS test imageuses: docker/build-push-action@10e90e3645eae34f1e60eeb005ba3a3d33f178e8 # v6.19.2with:@@ -65,8 +98,13 @@ jobs:file: backend/Dockerfile.dev.fipsload: truetags: infisical-backend-fips:latest- cache-from: type=gha- cache-to: type=gha,mode=max+ build-args: |+ TOOLCHAIN_IMAGE=${{ steps.toolchain.outputs.image }}+ - name: Report disk space+ if: always()+ run: df -h /+ - name: Wait for Secret Rotation testing databases+ run: docker compose -f docker-compose.e2e-dbs.yml up -d --wait --wait-timeout 300- name: Run integration testrun: |docker run --rm --network host \@@ -84,5 +122,7 @@ jobs:infisical-backend-fips:latest \npm run test:e2e- name: cleanup+ if: always()run: |docker compose -f "docker-compose.dev.yml" down+ docker compose -f "docker-compose.e2e-dbs.yml" downdiff --git a/backend/CLAUDE.md b/backend/CLAUDE.mdindex 12242b99c5..ab642a0964 100644--- a/backend/CLAUDE.md+++ b/backend/CLAUDE.md@@ -24,6 +24,39 @@ Unit tests go next to source as `*.test.ts` and test pure functions with VitestE2E tests live in `e2e-test/routes/`. The custom Vitest environment (`e2e-test/vitest-environment-knex.ts`) bootstraps a full server with DB, Redis, and encryption. Tests use injected globals: `testServer` (Fastify instance), `jwtAuthToken` (pre-authenticated JWT). Use `testServer.inject()` for HTTP assertions. Test helpers in `e2e-test/testUtils/` provide CRUD wrappers for secrets, folders, and secret imports. See `e2e-test/routes/v1/org.spec.ts` for a representative e2e test.+#### FIPS test image and the prebuilt toolchain++CI (`.github/workflows/run-backend-tests.yml`) runs the e2e suite inside a FIPS image built+from `Dockerfile.dev.fips`. The expensive, rarely-changing parts of that image (SoftHSM2,+Oracle Instant Client, the FIPS OpenSSL 3.1.2 build and the PQC OpenSSL 3.5.6 build) live in+**`Dockerfile.fips-toolchain`**, which is published to+`ghcr.io/infisical/backend-fips-toolchain` for amd64 and arm64 by+`.github/workflows/publish-fips-toolchain.yml` on pushes to `main`.++`Dockerfile.dev.fips` consumes it via the `TOOLCHAIN_IMAGE` build arg, so CI and local dev+pull the toolchain instead of spending ~15min compiling it. Consequences worth knowing:++- **Editing `Dockerfile.fips-toolchain` is expensive.** CI pins the image by the content hash+ of that file, so a PR touching it has no published tag and rebuilds from source (the old,+ slow path). It publishes once the PR lands on `main`. Keep app-level changes in+ `Dockerfile.dev.fips`.+- **Don't add `cache-to: type=gha` back to the image build.** GHA cache is PR-scoped (so it+ never hits on a PR's first run) and the repo's 10GB cache budget is already full; writing+ image blobs there evicts the `node_modules` caches of every workflow.+- **The published image is an internal CI build cache, not a supported artifact.** It is+ public only so CI and local dev can pull it; it carries no support or compatibility+ guarantee. It is *not* the FIPS product image — that is `infisical/infisical-fips`, built+ from `Dockerfile.fips.standalone-infisical`. OCI labels on the image say the same.+- **Keep every third-party fetch pinned and checksummed.** SoftHSM2 is pinned to a commit+ SHA (tags are mutable); both OpenSSL tarballs and the Oracle Instant Client zip are+ SHA256-verified; the Infisical CLI apt package is version-pinned. Oracle Instant Client+ is redistributed under the Oracle Free Distribution, Hosting, and Use Terms, which+ require the license to travel with it — `/opt/oracle/instantclient_23_26/BASIC_LICENSE`+ must not be removed.+- To iterate on the toolchain locally:+ `docker build -f backend/Dockerfile.fips-toolchain -t fips-toolchain:local backend` then+ `TOOLCHAIN_IMAGE=fips-toolchain:local docker compose -f docker-compose.dev.yml build backend`.+### Database- `npm run migration:new` — create new migration (interactive prompt)diff --git a/backend/Dockerfile.dev.fips b/backend/Dockerfile.dev.fipsindex a2a0c4bf53..956cd78aa6 100644--- a/backend/Dockerfile.dev.fips+++ b/backend/Dockerfile.dev.fips@@ -1,102 +1,5 @@-FROM node:22.22.0-trixie-slim--# ? Setup a test SoftHSM module. In production a real HSM is used.--ARG SOFTHSM2_VERSION=2.5.0--ENV SOFTHSM2_VERSION=${SOFTHSM2_VERSION} \- SOFTHSM2_SOURCES=/tmp/softhsm2--# Install all build and runtime dependencies-RUN apt-get update && apt-get install -y \- build-essential \- autoconf \- automake \- git \- libtool \- libssl-dev \- python3 \- make \- g++ \- openssh-client \- curl \- pkg-config \- perl \- wget \- unzip \- libaio1t64 \- unixodbc \- unixodbc-dev \- freetds-dev \- freetds-bin \- tdsodbc \- opensc \- smbclient \- && curl -1sLf 'https://artifacts-cli.infisical.com/setup.deb.sh' | bash \- && apt-get update && apt-get install -y infisical=0.43.79 \- && rm -rf /var/lib/apt/lists/*--# Create libaio symlink for Oracle Instant Client-RUN ARCH=$(dpkg --print-architecture) && \- if [ "$ARCH" = "arm64" ]; then \- ln -sf /lib/aarch64-linux-gnu/libaio.so.1t64 /lib/aarch64-linux-gnu/libaio.so.1; \- fi--RUN printf "[FreeTDS]\nDescription = FreeTDS Driver\nDriver = /usr/lib/x86_64-linux-gnu/odbc/libtdsodbc.so\nSetup = /usr/lib/x86_64-linux-gnu/odbc/libtdsodbc.so\nFileUsage = 1\n" > /etc/odbcinst.ini--# Build and install SoftHSM2-RUN git clone https://github.com/opendnssec/SoftHSMv2.git ${SOFTHSM2_SOURCES}-WORKDIR ${SOFTHSM2_SOURCES}--RUN git checkout ${SOFTHSM2_VERSION} -b ${SOFTHSM2_VERSION} \- && sh autogen.sh \- && ./configure --prefix=/usr/local --disable-gost \- && make \- && make install--WORKDIR /root-RUN rm -fr ${SOFTHSM2_SOURCES}--# Install Oracle Instant Client for OracleDB mTLS (Wallet) support-RUN mkdir -p /opt/oracle && \- ARCH=$(dpkg --print-architecture) && \- if [ "$ARCH" = "arm64" ]; then \- EXPECTED_SHA="9c9a32051e97f087016fb334b7ad5c0aea8511ca8363afd8e0dc6ec4fc515c32" && \- curl -o /tmp/instantclient.zip https://download.oracle.com/otn_software/linux/instantclient/2326000/instantclient-basic-linux.arm64-23.26.0.0.0.zip; \- else \- EXPECTED_SHA="d6c79cbcf0ff209363e779855c690d4fc730aed847e9198a2c439bcf34760af5" && \- curl -o /tmp/instantclient.zip https://download.oracle.com/otn_software/linux/instantclient/2326000/instantclient-basic-linux.x64-23.26.0.0.0.zip; \- fi && \- echo "$EXPECTED_SHA /tmp/instantclient.zip" | sha256sum -c - && \- unzip -oq /tmp/instantclient.zip -d /opt/oracle && \- rm /tmp/instantclient.zip && \- echo /opt/oracle/instantclient_23_26 > /etc/ld.so.conf.d/oracle-instantclient.conf && \- ldconfig--WORKDIR /openssl-build-RUN wget https://www.openssl.org/source/openssl-3.1.2.tar.gz \- && tar -xf openssl-3.1.2.tar.gz \- && cd openssl-3.1.2 \- && ./Configure enable-fips --libdir=lib \- && make \- && make install_fips \- && test -f /usr/local/lib/ossl-modules/fips.so \- && cd / \- && rm -rf /openssl-build \- && apt-get clean \- && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*--# Build OpenSSL 3.5.6 for PQC (ML-DSA / SLH-DSA) certificate support.-WORKDIR /tmp/openssl-pqc-build-RUN wget -q https://github.com/openssl/openssl/releases/download/openssl-3.5.6/openssl-3.5.6.tar.gz \- && echo "deae7c80cba99c4b4f940ecadb3c3338b13cb77418409238e57d7f31f2a3b736 openssl-3.5.6.tar.gz" | sha256sum -c - \- && tar -xf openssl-3.5.6.tar.gz \- && cd openssl-3.5.6 \- && ./Configure --prefix=/opt/openssl-pqc --openssldir=/opt/openssl-pqc/ssl no-docs \- && make -j"$(nproc)" \- && make install_sw \- && cd / \- && rm -rf /tmp/openssl-pqc-build+ARG TOOLCHAIN_IMAGE=ghcr.io/infisical/backend-fips-toolchain:main+FROM ${TOOLCHAIN_IMAGE}# ? App setupdiff --git a/backend/Dockerfile.fips-toolchain b/backend/Dockerfile.fips-toolchainnew file mode 100644index 0000000000..40f9823893--- /dev/null+++ b/backend/Dockerfile.fips-toolchain@@ -0,0 +1,127 @@+# Build toolchain for the FIPS test/dev image.+#+# This layer is expensive (~15 min from scratch: two OpenSSL builds, SoftHSM2, Oracle+# Instant Client) and changes very rarely, so it is published to GHCR by+# .github/workflows/publish-fips-toolchain.yml and consumed by Dockerfile.dev.fips.+#+# Anything edited here changes the published tag, so CI will rebuild it from source on+# the PR that changes it and publish the new tag once that PR lands on main.+#+# SCOPE: this is an internal CI build cache, not a supported Infisical artifact. It is+# published publicly only so CI and local dev can pull it instead of recompiling. It is+# not part of any public API, carries no support or compatibility guarantee, and its tags+# may change or be deleted at any time. It is NOT the FIPS product image — that is+# infisical/infisical-fips, built from Dockerfile.fips.standalone-infisical.+#+# THIRD-PARTY CONTENTS: includes Oracle Instant Client, redistributed under the Oracle+# Free Distribution, Hosting, and Use Terms and Conditions, which permit redistribution+# of the unmodified Program provided a copy of the license accompanies it. That copy+# ships in the image at /opt/oracle/instantclient_23_26/BASIC_LICENSE and must not be+# removed. Also includes OpenSSL (Apache-2.0), SoftHSM2 (BSD-2-Clause), the Infisical+# CLI, and Debian packages under their respective licenses.++FROM node:22.22.0-trixie-slim++ARG SOFTHSM2_VERSION=2.5.0+ARG SOFTHSM2_COMMIT=369df0383d101bc8952692c2a368ac8bc887d1b4++ENV SOFTHSM2_VERSION=${SOFTHSM2_VERSION} \+ SOFTHSM2_SOURCES=/tmp/softhsm2++RUN apt-get update && apt-get install -y \+ build-essential \+ autoconf \+ automake \+ git \+ libtool \+ libssl-dev \+ python3 \+ make \+ g++ \+ openssh-client \+ curl \+ pkg-config \+ perl \+ wget \+ unzip \+ libaio1t64 \+ unixodbc \+ unixodbc-dev \+ freetds-dev \+ freetds-bin \+ tdsodbc \+ opensc \+ smbclient \+ && curl -1sLf 'https://artifacts-cli.infisical.com/setup.deb.sh' | bash \+ && apt-get update && apt-get install -y infisical=0.43.79 \+ && rm -rf /var/lib/apt/lists/*++RUN ARCH=$(dpkg --print-architecture) && \+ if [ "$ARCH" = "arm64" ]; then \+ ln -sf /lib/aarch64-linux-gnu/libaio.so.1t64 /lib/aarch64-linux-gnu/libaio.so.1; \+ fi++RUN printf "[FreeTDS]\nDescription = FreeTDS Driver\nDriver = /usr/lib/x86_64-linux-gnu/odbc/libtdsodbc.so\nSetup = /usr/lib/x86_64-linux-gnu/odbc/libtdsodbc.so\nFileUsage = 1\n" > /etc/odbcinst.ini++RUN git clone https://github.com/opendnssec/SoftHSMv2.git ${SOFTHSM2_SOURCES}+WORKDIR ${SOFTHSM2_SOURCES}++RUN git checkout --detach "${SOFTHSM2_COMMIT}" \+ && test "$(git rev-parse HEAD)" = "${SOFTHSM2_COMMIT}" \+ && sh autogen.sh \+ && ./configure --prefix=/usr/local --disable-gost \+ && make \+ && make install++WORKDIR /root+RUN rm -fr ${SOFTHSM2_SOURCES}++RUN mkdir -p /opt/oracle && \+ ARCH=$(dpkg --print-architecture) && \+ if [ "$ARCH" = "arm64" ]; then \+ EXPECTED_SHA="9c9a32051e97f087016fb334b7ad5c0aea8511ca8363afd8e0dc6ec4fc515c32" && \+ curl -o /tmp/instantclient.zip https://download.oracle.com/otn_software/linux/instantclient/2326000/instantclient-basic-linux.arm64-23.26.0.0.0.zip; \+ else \+ EXPECTED_SHA="d6c79cbcf0ff209363e779855c690d4fc730aed847e9198a2c439bcf34760af5" && \+ curl -o /tmp/instantclient.zip https://download.oracle.com/otn_software/linux/instantclient/2326000/instantclient-basic-linux.x64-23.26.0.0.0.zip; \+ fi && \+ echo "$EXPECTED_SHA /tmp/instantclient.zip" | sha256sum -c - && \+ unzip -oq /tmp/instantclient.zip -d /opt/oracle && \+ rm /tmp/instantclient.zip && \+ echo /opt/oracle/instantclient_23_26 > /etc/ld.so.conf.d/oracle-instantclient.conf && \+ ldconfig++WORKDIR /openssl-build+RUN wget https://www.openssl.org/source/openssl-3.1.2.tar.gz \+ && echo "a0ce69b8b97ea6a35b96875235aa453b966ba3cba8af2de23657d8b6767d6539 openssl-3.1.2.tar.gz" | sha256sum -c - \+ && tar -xf openssl-3.1.2.tar.gz \+ && cd openssl-3.1.2 \+ && ./Configure enable-fips --libdir=lib \+ && make -j"$(nproc)" \+ && make install_fips \+ && test -f /usr/local/lib/ossl-modules/fips.so \+ && cd / \+ && rm -rf /openssl-build \+ && apt-get clean \+ && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*++WORKDIR /tmp/openssl-pqc-build+RUN wget -q https://github.com/openssl/openssl/releases/download/openssl-3.5.6/openssl-3.5.6.tar.gz \+ && echo "deae7c80cba99c4b4f940ecadb3c3338b13cb77418409238e57d7f31f2a3b736 openssl-3.5.6.tar.gz" | sha256sum -c - \+ && tar -xf openssl-3.5.6.tar.gz \+ && cd openssl-3.5.6 \+ && ./Configure --prefix=/opt/openssl-pqc --openssldir=/opt/openssl-pqc/ssl no-docs \+ && make -j"$(nproc)" \+ && make install_sw \+ && cd / \+ && rm -rf /tmp/openssl-pqc-build++WORKDIR /app++LABEL org.opencontainers.image.title="Infisical backend FIPS test toolchain" \+ org.opencontainers.image.description="Internal CI build cache for Infisical's backend FIPS test image (Dockerfile.dev.fips). Not a supported or versioned public artifact: no support or compatibility guarantee, tags may change or be deleted without notice, and it is not the FIPS product image (that is infisical/infisical-fips). Do not depend on it outside Infisical CI and local development." \+ org.opencontainers.image.source="https://github.com/Infisical/infisical" \+ org.opencontainers.image.licenses="NOASSERTION" \+ com.infisical.image.internal="true" \+ com.infisical.image.supported="false" \+ com.infisical.thirdparty.oracle-instantclient.license="/opt/oracle/instantclient_23_26/BASIC_LICENSE"diff --git a/docker-compose.dev.yml b/docker-compose.dev.ymlindex d6107957dd..d951284ac5 100644--- a/docker-compose.dev.yml+++ b/docker-compose.dev.yml@@ -97,6 +97,8 @@ services:build:context: ./backenddockerfile: Dockerfile.dev.fips+ args:+ TOOLCHAIN_IMAGE: ${TOOLCHAIN_IMAGE:-ghcr.io/infisical/backend-fips-toolchain:main}depends_on:db:condition: service_started