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): allow unbound auth configs saved before the enforcement cutoff
Calvin8edbf16cc3d0
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 23476fe44c..c88d11b27f 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@@ -25,6 +25,7 @@ import {recordAuthAttemptMetric} from "@app/lib/telemetry/metrics";import { TEventEmitter } from "@app/services/event-outbox/event-outbox-types";+import { isUnboundAuthGrandfathered } from "@app/services/identity/identity-auth-trust-binding-fns";import {emitIdentityAuthMethodChanged,IdentityAuthMethodChange@@ -155,16 +156,21 @@ export const identityAwsAuthServiceFactory = ({try {if (!hasAwsTrustBinding(identityAwsAuth)) {- 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.",- detail: {- reasonCode: "trust_binding_missing",- identityId: identity.id,- orgId: identity.orgId,- identityName: identity.name- }- });+ if (!isUnboundAuthGrandfathered(identityAwsAuth.createdAt)) {+ 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.",+ detail: {+ reasonCode: "trust_binding_missing",+ identityId: identity.id,+ orgId: identity.orgId,+ identityName: identity.name+ }+ });+ }+ logger.warn(+ `AWS Auth Login: identity has no trust binding and its auth config predates enforcement, allowing [identity-id=${identity.id}]`+ );}const headers: TAwsGetCallerIdentityHeaders = JSON.parse(Buffer.from(iamRequestHeaders, "base64").toString());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 6d6242acce..fcc3ba8a9a 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,5 +1,6 @@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";@@ -18,6 +19,10 @@ vi.mock("@app/lib/config/env", () => ({getConfig: () => ({ OTEL_TELEMETRY_COLLECTION_ENABLED: false })}));+vi.mock("@app/lib/logger", () => ({+ logger: { info: vi.fn(), warn: vi.fn(), error: vi.fn(), debug: vi.fn() }+}));+vi.mock("@fastify/request-context", () => ({requestContext: { get: vi.fn(() => undefined) }}));@@ -25,6 +30,8 @@ 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]";@@ -39,6 +46,7 @@ const computeEngineDetails = {};type TGcpAuthRow = {+ createdAt: Date;type: "gce" | "iam";allowedServiceAccounts: string | null;allowedProjects: string | null;@@ -55,6 +63,7 @@ const makeService = (gcpAuth: Partial<TGcpAuthRow> = {}) => {identityGcpAuthDAL: {findOne: vi.fn().mockResolvedValue({identityId: IDENTITY_ID,+ createdAt: AFTER_CUTOFF,type: "gce",allowedServiceAccounts: null,allowedProjects: null,@@ -230,3 +239,30 @@ describe("gcpAuthService.login trust binding", () => {await expect(result).rejects.toMatchObject({ detail: { reasonCode: "trust_binding_missing" } });});});++describe("gcpAuthService.login unbound identities from before the cutoff", () => {+ test("allows a GCE identity with no binding whose auth config predates the cutoff", async () => {+ const { result, issueIdentityAccessToken } = login(+ { type: "gce", createdAt: BEFORE_CUTOFF },+ { email: SERVICE_ACCOUNT, computeEngineDetails }+ );++ await expect(result).resolves.toMatchObject({ accessToken: ACCESS_TOKEN });+ 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 });++ 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 }+ );++ 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 837fedf3e0..0a63ffa568 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@@ -9,6 +9,7 @@ import { ProjectPermissionIdentityActions, ProjectPermissionSub } from "@app/ee/import { TKeyStoreFactory } from "@app/keystore/keystore";import { getConfig } from "@app/lib/config/env";import { BadRequestError, ForbiddenRequestError, NotFoundError, UnauthorizedError } from "@app/lib/errors";+import { logger } from "@app/lib/logger";import { extractIPDetails, isValidIpOrCidr, TIp } from "@app/lib/ip";import { requestMemoKeys } from "@app/lib/request-context/memo-keys";import { RequestContextKey } from "@app/lib/request-context/request-context-keys";@@ -20,6 +21,7 @@ import {recordAuthAttemptMetric} from "@app/lib/telemetry/metrics";import { TEventEmitter } from "@app/services/event-outbox/event-outbox-types";+import { isUnboundAuthGrandfathered } from "@app/services/identity/identity-auth-trust-binding-fns";import {emitIdentityAuthMethodChanged,IdentityAuthMethodChange@@ -109,16 +111,21 @@ export const identityGcpAuthServiceFactory = ({try {if (!hasGcpTrustBinding(identityGcpAuth)) {- 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.",- detail: {- reasonCode: "trust_binding_missing",- identityId: identity.id,- orgId: identity.orgId,- identityName: identity.name- }- });+ if (!isUnboundAuthGrandfathered(identityGcpAuth.createdAt)) {+ 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.",+ detail: {+ reasonCode: "trust_binding_missing",+ identityId: identity.id,+ orgId: identity.orgId,+ identityName: identity.name+ }+ });+ }+ logger.warn(+ `GCP Auth Login: identity has no trust binding and its auth config predates enforcement, allowing [identity-id=${identity.id}]`+ );}let gcpIdentityDetails: TGcpIdentityDetails;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.tsnew file mode 100644index 0000000000..e116ec4b17--- /dev/null+++ b/backend/src/services/identity/identity-auth-trust-binding-fns.test.ts@@ -0,0 +1,17 @@+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.tsnew file mode 100644index 0000000000..796a343948--- /dev/null+++ b/backend/src/services/identity/identity-auth-trust-binding-fns.ts@@ -0,0 +1,5 @@+// 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;