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(pam): address GCP IAM review feedback
bernie-g11590ef3b333
diff --git a/backend/src/ee/services/pam-account/pam-account-schemas.ts b/backend/src/ee/services/pam-account/pam-account-schemas.tsindex 471b6aed48..3df04ce76d 100644--- a/backend/src/ee/services/pam-account/pam-account-schemas.ts+++ b/backend/src/ee/services/pam-account/pam-account-schemas.ts@@ -7,7 +7,7 @@ import { z } from "zod";import { BadRequestError } from "@app/lib/errors";-import { PamAccountType } from "../pam/pam-enums";+import { GcpIamAuthMethod, PamAccountType } from "../pam/pam-enums";import { getApplicablePolicies, PamPolicyDescriptorSchema } from "../pam/pam-policies";import {PamAccountSettingsOverridesSchema,@@ -388,18 +388,41 @@ export const ACCOUNT_TYPE_CONFIGS = {},[PamAccountType.GcpIam]: {- name: "Google Cloud IAM",+ name: "GCP Service Account",icon: "Google Cloud Platform.png",connectionDetails: z.object({- serviceAccountEmail: z.string().trim().min(1).max(255)+ serviceAccountEmail: z+ .string()+ .trim()+ .min(1)+ .max(255)+ .email("Must be a valid service account email address")+ .refine((val) => val.endsWith(".iam.gserviceaccount.com"), {+ message: "Must be a GCP service account email (ending in .iam.gserviceaccount.com)"+ })}),credentials: z.discriminatedUnion("authMethod", [z.object({- authMethod: z.literal("impersonation")+ authMethod: z.literal(GcpIamAuthMethod.Impersonation)}),z.object({- authMethod: z.literal("static-key"),- serviceAccountKeyJson: z.string().trim().min(1).max(8192)+ authMethod: z.literal(GcpIamAuthMethod.StaticKey),+ serviceAccountKeyJson: z+ .string()+ .trim()+ .min(1)+ .max(8192)+ .refine(+ (val) => {+ try {+ const parsed = JSON.parse(val) as Record<string, unknown>;+ return typeof parsed.client_email === "string" && typeof parsed.private_key === "string";+ } catch {+ return false;+ }+ },+ { message: "Must be valid JSON containing client_email and private_key fields" }+ )})]),sanitizedCredentials: z.object({@@ -409,10 +432,12 @@ export const ACCOUNT_TYPE_CONFIGS = {serviceAccountEmail: { label: "Service Account Email" },authMethod: {label: "Auth Method",- defaultValue: "impersonation",+ tooltip:+ "Impersonation uses the platform's GCP identity to generate short-lived tokens for the target service account. Static Key uses a service account key JSON stored directly in the PAM account.",+ defaultValue: GcpIamAuthMethod.Impersonation,options: [- { label: "Impersonation (Recommended)", value: "impersonation" },- { label: "Static Key", value: "static-key" }+ { label: "Impersonation (Recommended)", value: GcpIamAuthMethod.Impersonation },+ { label: "Static Key", value: GcpIamAuthMethod.StaticKey }]},serviceAccountKeyJson: {diff --git a/backend/src/ee/services/pam-session/pam-session-service.ts b/backend/src/ee/services/pam-session/pam-session-service.tsindex a4014bd4ff..832b2364e5 100644--- a/backend/src/ee/services/pam-session/pam-session-service.ts+++ b/backend/src/ee/services/pam-session/pam-session-service.ts@@ -23,7 +23,7 @@ import { TMfaSessionServiceFactory } from "@app/services/mfa-session/mfa-sessionimport { TOrgDALFactory } from "@app/services/org/org-dal";import { TUserDALFactory } from "@app/services/user/user-dal";-import { PamAccessMethod, PamAccountType, PamSessionStatus } from "../pam/pam-enums";+import { GcpIamAuthMethod, PamAccessMethod, PamAccountType, PamSessionStatus } from "../pam/pam-enums";import { enforceMfa } from "../pam/pam-mfa";import {checkAccountAccess,@@ -219,10 +219,10 @@ export const pamSessionServiceFactory = ({const sessionTtlSeconds = Math.min(remainingSeconds, 3600);let sourceClient;- if (credentials.authMethod === "static-key") {+ if (credentials.authMethod === GcpIamAuthMethod.StaticKey) {const keyJson = JSON.parse(credentials.serviceAccountKeyJson as string) as {- client_email?: string;- private_key?: string;+ client_email: string;+ private_key: string;};sourceClient = new JWT({email: keyJson.client_email,diff --git a/backend/src/ee/services/pam/pam-enums.ts b/backend/src/ee/services/pam/pam-enums.tsindex a7e5a37583..d5a447161d 100644--- a/backend/src/ee/services/pam/pam-enums.ts+++ b/backend/src/ee/services/pam/pam-enums.ts@@ -32,6 +32,11 @@ export enum PamSessionStatus {Terminated = "terminated"}+export enum GcpIamAuthMethod {+ Impersonation = "impersonation",+ StaticKey = "static-key"+}+export enum PamAccessMethod {Web = "web",Cli = "cli"