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
fix(identity-auth): gate unbound logins on a requireAllowList column instead of a date
Calvin08cc7d0d492c
diff --git a/backend/src/db/migrations/20261021120000_identity-aws-gcp-auth-require-allow-list.ts b/backend/src/db/migrations/20261021120000_identity-aws-gcp-auth-require-allow-list.tsnew file mode 100644index 0000000000..e37caad178--- /dev/null+++ b/backend/src/db/migrations/20261021120000_identity-aws-gcp-auth-require-allow-list.ts@@ -0,0 +1,35 @@+import { Knex } from "knex";++import { TableName } from "../schemas";++const TABLES = [TableName.IdentityAwsAuth, TableName.IdentityGcpAuth];++export async function up(knex: Knex): Promise<void> {+ for (const tableName of TABLES) {+ // eslint-disable-next-line no-await-in-loop+ const hasColumn = await knex.schema.hasColumn(tableName, "requireAllowList");+ if (!hasColumn) {+ // eslint-disable-next-line no-await-in-loop+ await knex.schema.alterTable(tableName, (t) => {+ t.boolean("requireAllowList").notNullable().defaultTo(false);+ });+ // Rows that exist now were saved before the allow list was enforced, so they get false. Flipping the+ // default afterwards means every row created from here on is enforced, with no backfill needed.+ // eslint-disable-next-line no-await-in-loop+ await knex.raw(`ALTER TABLE ?? ALTER COLUMN "requireAllowList" SET DEFAULT true`, [tableName]);+ }+ }+}++export async function down(knex: Knex): Promise<void> {+ for (const tableName of TABLES) {+ // eslint-disable-next-line no-await-in-loop+ const hasColumn = await knex.schema.hasColumn(tableName, "requireAllowList");+ if (hasColumn) {+ // eslint-disable-next-line no-await-in-loop+ await knex.schema.alterTable(tableName, (t) => {+ t.dropColumn("requireAllowList");+ });+ }+ }+}diff --git a/backend/src/db/schemas/identity-aws-auths.ts b/backend/src/db/schemas/identity-aws-auths.tsindex 83f5b43cf3..0efd26f968 100644--- a/backend/src/db/schemas/identity-aws-auths.ts+++ b/backend/src/db/schemas/identity-aws-auths.ts@@ -20,7 +20,8 @@ export const IdentityAwsAuthsSchema = z.object({stsEndpoint: z.string(),allowedPrincipalArns: z.string(),allowedAccountIds: z.string(),- accessTokenPeriod: z.coerce.number().default(0)+ accessTokenPeriod: z.coerce.number().default(0),+ requireAllowList: z.boolean().default(true)});export type TIdentityAwsAuths = z.infer<typeof IdentityAwsAuthsSchema>;diff --git a/backend/src/db/schemas/identity-gcp-auths.ts b/backend/src/db/schemas/identity-gcp-auths.tsindex 536e7200aa..b8d438d1e7 100644--- a/backend/src/db/schemas/identity-gcp-auths.ts+++ b/backend/src/db/schemas/identity-gcp-auths.ts@@ -20,7 +20,8 @@ export const IdentityGcpAuthsSchema = z.object({allowedServiceAccounts: z.string().nullable().optional(),allowedProjects: z.string().nullable().optional(),allowedZones: z.string().nullable().optional(),- accessTokenPeriod: z.coerce.number().default(0)+ accessTokenPeriod: z.coerce.number().default(0),+ requireAllowList: z.boolean().default(true)});export type TIdentityGcpAuths = z.infer<typeof IdentityGcpAuthsSchema>;diff --git a/backend/src/services/identity-aws-auth/identity-aws-auth-service.ts b/backend/src/services/identity-aws-auth/identity-aws-auth-service.tsindex 329fd889d8..5b4e96d7e5 100644--- a/backend/src/services/identity-aws-auth/identity-aws-auth-service.ts+++ b/backend/src/services/identity-aws-auth/identity-aws-auth-service.ts@@ -29,7 +29,6 @@ import {emitIdentityAuthMethodChanged,IdentityAuthMethodChange} from "@app/services/identity/identity-auth-method-events";-import { isUnboundAuthGrandfathered } from "@app/services/identity/identity-auth-trust-binding-fns";import { ActorType } from "../auth/auth-type";import { assertIdentityAuthAccessAllowed } from "../identity/identity-auth-permission-fns";@@ -156,7 +155,7 @@ export const identityAwsAuthServiceFactory = ({try {if (!hasAwsTrustBinding(identityAwsAuth)) {- if (!isUnboundAuthGrandfathered(identityAwsAuth.createdAt)) {+ if (identityAwsAuth.requireAllowList) {throw new UnauthorizedError({message:"Access denied: this identity has no AWS account ID or principal ARN configured. An admin must add one before it can authenticate.",@@ -450,6 +449,7 @@ export const identityAwsAuthServiceFactory = ({identityId: identityMembershipOrg.identity.id,type: "iam",stsEndpoint,+ requireAllowList: true,allowedPrincipalArns,allowedAccountIds,accessTokenMaxTTL,@@ -566,6 +566,7 @@ export const identityAwsAuthServiceFactory = ({identityAwsAuth.id,{stsEndpoint,+ requireAllowList: true,allowedPrincipalArns,allowedAccountIds,accessTokenMaxTTL,diff --git a/backend/src/services/identity-gcp-auth/identity-gcp-auth-service.test.ts b/backend/src/services/identity-gcp-auth/identity-gcp-auth-service.test.tsindex 57c74263ee..d40bb4bb7b 100644--- a/backend/src/services/identity-gcp-auth/identity-gcp-auth-service.test.ts+++ b/backend/src/services/identity-gcp-auth/identity-gcp-auth-service.test.ts@@ -1,6 +1,5 @@import { beforeEach, describe, expect, test, vi } from "vitest";-import { UNBOUND_AUTH_CUTOFF } from "../identity/identity-auth-trust-binding-fns";import { identityGcpAuthServiceFactory } from "./identity-gcp-auth-service";import { TGcpIdentityDetails } from "./identity-gcp-auth-types";@@ -30,8 +29,6 @@ vi.mock("@fastify/request-context", () => ({const IDENTITY_ID = "5d3a8b2e-7c61-4b0f-9f3e-2a1c4d6e8f90";const ORG_ID = "org-id";const ACCESS_TOKEN = "access-token";-const AFTER_CUTOFF = new Date(UNBOUND_AUTH_CUTOFF.getTime() + 24 * 60 * 60 * 1000);-const BEFORE_CUTOFF = new Date(UNBOUND_AUTH_CUTOFF.getTime() - 24 * 60 * 60 * 1000);const SERVICE_ACCOUNT = "[email protected]";const OTHER_SERVICE_ACCOUNT = "[email protected]";@@ -46,7 +43,7 @@ const computeEngineDetails = {};type TGcpAuthRow = {- createdAt: Date;+ requireAllowList: boolean;type: "gce" | "iam";allowedServiceAccounts: string | null;allowedProjects: string | null;@@ -63,7 +60,7 @@ const makeService = (gcpAuth: Partial<TGcpAuthRow> = {}) => {identityGcpAuthDAL: {findOne: vi.fn().mockResolvedValue({identityId: IDENTITY_ID,- createdAt: AFTER_CUTOFF,+ requireAllowList: true,type: "gce",allowedServiceAccounts: null,allowedProjects: null,@@ -251,10 +248,10 @@ describe("gcpAuthService.login trust binding", () => {});});-describe("gcpAuthService.login unbound identities from before the cutoff", () => {- test("allows a GCE identity with no binding whose auth config predates the cutoff", async () => {+describe("gcpAuthService.login legacy identities that do not require an allow list", () => {+ test("allows a GCE identity with no binding saved before the allow list was required", async () => {const { result, issueIdentityAccessToken } = login(- { type: "gce", createdAt: BEFORE_CUTOFF },+ { type: "gce", requireAllowList: false },{ email: SERVICE_ACCOUNT, computeEngineDetails });@@ -262,17 +259,14 @@ describe("gcpAuthService.login unbound identities from before the cutoff", () =>expect(issueIdentityAccessToken).toHaveBeenCalledTimes(1);});- test("allows an IAM identity with no binding whose auth config predates the cutoff", async () => {- const { result } = login({ type: "iam", createdAt: BEFORE_CUTOFF }, { email: SERVICE_ACCOUNT });+ test("allows an IAM identity with no binding saved before the allow list was required", async () => {+ const { result } = login({ type: "iam", requireAllowList: false }, { email: SERVICE_ACCOUNT });await expect(result).resolves.toMatchObject({ accessToken: ACCESS_TOKEN });});- test("denies an unbound identity whose auth config is created at the cutoff", async () => {- const { result } = login(- { type: "gce", createdAt: UNBOUND_AUTH_CUTOFF },- { email: SERVICE_ACCOUNT, computeEngineDetails }- );+ test("denies an unbound identity once the allow list is required", async () => {+ const { result } = login({ type: "gce", requireAllowList: true }, { email: SERVICE_ACCOUNT, computeEngineDetails });await expect(result).rejects.toMatchObject({ detail: { reasonCode: "trust_binding_missing" } });});diff --git a/backend/src/services/identity-gcp-auth/identity-gcp-auth-service.ts b/backend/src/services/identity-gcp-auth/identity-gcp-auth-service.tsindex f162b9f159..f7b74f9091 100644--- a/backend/src/services/identity-gcp-auth/identity-gcp-auth-service.ts+++ b/backend/src/services/identity-gcp-auth/identity-gcp-auth-service.ts@@ -25,7 +25,6 @@ import {emitIdentityAuthMethodChanged,IdentityAuthMethodChange} from "@app/services/identity/identity-auth-method-events";-import { isUnboundAuthGrandfathered } from "@app/services/identity/identity-auth-trust-binding-fns";import { ActorType } from "../auth/auth-type";import { assertIdentityAuthAccessAllowed } from "../identity/identity-auth-permission-fns";@@ -111,7 +110,7 @@ export const identityGcpAuthServiceFactory = ({try {if (!hasGcpTrustBinding(identityGcpAuth)) {- if (!isUnboundAuthGrandfathered(identityGcpAuth.createdAt)) {+ if (identityGcpAuth.requireAllowList) {throw new UnauthorizedError({message:"Access denied: this identity has no GCP service account, project, or zone configured. An admin must add one before it can authenticate.",@@ -408,6 +407,7 @@ export const identityGcpAuthServiceFactory = ({{identityId: identityMembershipOrg.identity.id,type,+ requireAllowList: true,allowedServiceAccounts,allowedProjects,allowedZones,@@ -527,6 +527,7 @@ export const identityGcpAuthServiceFactory = ({identityGcpAuth.id,{type,+ requireAllowList: true,allowedServiceAccounts,allowedProjects,allowedZones,diff --git a/backend/src/services/identity/identity-auth-trust-binding-fns.test.ts b/backend/src/services/identity/identity-auth-trust-binding-fns.test.tsdeleted file mode 100644index e116ec4b17..0000000000--- a/backend/src/services/identity/identity-auth-trust-binding-fns.test.ts+++ /dev/null@@ -1,17 +0,0 @@-import { describe, expect, test } from "vitest";--import { isUnboundAuthGrandfathered, UNBOUND_AUTH_CUTOFF } from "./identity-auth-trust-binding-fns";--describe("isUnboundAuthGrandfathered", () => {- test("is true for an auth config saved before the cutoff", () => {- expect(isUnboundAuthGrandfathered(new Date(UNBOUND_AUTH_CUTOFF.getTime() - 1))).toBe(true);- });-- test("is false at the cutoff", () => {- expect(isUnboundAuthGrandfathered(new Date(UNBOUND_AUTH_CUTOFF.getTime()))).toBe(false);- });-- test("is false for an auth config saved after the cutoff", () => {- expect(isUnboundAuthGrandfathered(new Date(UNBOUND_AUTH_CUTOFF.getTime() + 1))).toBe(false);- });-});diff --git a/backend/src/services/identity/identity-auth-trust-binding-fns.ts b/backend/src/services/identity/identity-auth-trust-binding-fns.tsdeleted file mode 100644index 796a343948..0000000000--- a/backend/src/services/identity/identity-auth-trust-binding-fns.ts+++ /dev/null@@ -1,5 +0,0 @@-// Auth configs saved before this instant may log in without a trust binding, so enforcement does not-// break identities that were configured before it shipped. Any update still requires a binding.-export const UNBOUND_AUTH_CUTOFF = new Date("2026-10-21T00:00:00Z");--export const isUnboundAuthGrandfathered = (authCreatedAt: Date) => authCreatedAt < UNBOUND_AUTH_CUTOFF;