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
misc: addressed comments
Sheen Capadngan46cc569105cc
diff --git a/backend/src/ee/services/pam-account/pam-account-service.ts b/backend/src/ee/services/pam-account/pam-account-service.tsindex 343402a582..fe61155c63 100644--- a/backend/src/ee/services/pam-account/pam-account-service.ts+++ b/backend/src/ee/services/pam-account/pam-account-service.ts@@ -120,7 +120,7 @@ type TPamAccountServiceFactoryDep = {>;kmsService: Pick<TKmsServiceFactory, "createCipherPairWithDataKey">;gatewayV2DAL: Pick<TGatewayV2DALFactory, "findOne" | "find">;- gatewayPoolMembershipDAL: Pick<TGatewayPoolMembershipDALFactory, "find">;+ gatewayPoolMembershipDAL: Pick<TGatewayPoolMembershipDALFactory, "findHealthyGatewaysByPoolId">;gatewayV2Service: Pick<TGatewayV2ServiceFactory,"getPlatformConnectionDetailsByGatewayId" | "getPAMConnectionDetails"@@ -268,39 +268,41 @@ export const pamAccountServiceFactory = (deps: TPamAccountServiceFactoryDep) =>gatewayPoolId: a.gatewayPoolId ?? a.templateGatewayPoolId}));+ if (!candidates.some((c) => c.enabled)) return candidates.map(() => false);++ const supportsMasking = (gateway: { capabilities?: unknown }) =>+ (gateway.capabilities as { sessionLogMaskingBuiltInDetection?: boolean } | undefined)+ ?.sessionLogMaskingBuiltInDetection === true;++ // Only reachable members can serve a session, so an offline one lacking the capability must not+ // make the account look degraded. Same reachability filter pool selection uses.const poolIds = [...new Set(candidates.filter((c) => c.enabled && !c.gatewayId && c.gatewayPoolId).map((c) => c.gatewayPoolId!))];- const memberships = poolIds.length ? await gatewayPoolMembershipDAL.find({ $in: { gatewayPoolId: poolIds } }) : [];- const poolGatewayIds = new Map<string, string[]>();- memberships.forEach((m) => {- poolGatewayIds.set(m.gatewayPoolId, [...(poolGatewayIds.get(m.gatewayPoolId) ?? []), m.gatewayId]);- });+ const poolDegraded = new Map<string, boolean>();+ await Promise.all(+ poolIds.map(async (poolId) => {+ const healthy = await gatewayPoolMembershipDAL.findHealthyGatewaysByPoolId(poolId);+ poolDegraded.set(+ poolId,+ healthy.some((gateway) => !supportsMasking(gateway))+ );+ })+ );- const gatewayIds = [- ...new Set([- ...candidates.filter((c) => c.enabled && c.gatewayId).map((c) => c.gatewayId!),- ...[...poolGatewayIds.values()].flat()- ])- ];- const gatewayIdSet = new Set(gatewayIds);- const orgGateways = gatewayIdSet.size ? await gatewayV2DAL.find({ orgId }) : [];- const gateways = orgGateways.filter((g) => gatewayIdSet.has(g.id));+ const directIds = new Set(candidates.filter((c) => c.enabled && c.gatewayId).map((c) => c.gatewayId!));const unsupported = new Set(- gateways- .filter(- (g) =>- (g.capabilities as { sessionLogMaskingBuiltInDetection?: boolean } | undefined)- ?.sessionLogMaskingBuiltInDetection !== true- )- .map((g) => g.id)+ directIds.size+ ? (await gatewayV2DAL.find({ orgId }))+ .filter((g) => directIds.has(g.id) && !supportsMasking(g))+ .map((g) => g.id)+ : []);return candidates.map((c) => {if (!c.enabled) return false;if (c.gatewayId) return unsupported.has(c.gatewayId);- if (c.gatewayPoolId) return (poolGatewayIds.get(c.gatewayPoolId) ?? []).some((id) => unsupported.has(id));- return false;+ return poolDegraded.get(c.gatewayPoolId ?? "") ?? false;});};diff --git a/backend/src/ee/services/pam/pam-enums.ts b/backend/src/ee/services/pam/pam-enums.tsindex e2665b69df..1115fbebcd 100644--- a/backend/src/ee/services/pam/pam-enums.ts+++ b/backend/src/ee/services/pam/pam-enums.ts@@ -108,7 +108,8 @@ export enum PamAccountWarning {SessionLogMaskingDegraded = "session-log-masking-degraded"}-// These are brokered over RDP, whose recordings are base64 frames rather than terminal text, so-// the gateway never masks them.+// Whether sessions for this type produce a session log the gateway can mask.export const accountTypeSupportsSessionLogMasking = (accountType: PamAccountType): boolean =>- accountType !== PamAccountType.Windows && accountType !== PamAccountType.WindowsAd;+ accountType !== PamAccountType.Windows &&+ accountType !== PamAccountType.WindowsAd &&+ accountType !== PamAccountType.AwsIam;diff --git a/backend/src/ee/services/pam/pam-policies.test.ts b/backend/src/ee/services/pam/pam-policies.test.tsindex 79787f5ef9..bf28a14793 100644--- a/backend/src/ee/services/pam/pam-policies.test.ts+++ b/backend/src/ee/services/pam/pam-policies.test.ts@@ -217,15 +217,15 @@ describe("buildPamPolicyRules", () => {});describe("accountTypeSupportsSessionLogMasking", () => {- test("is false for the RDP-brokered types", () => {- expect(accountTypeSupportsSessionLogMasking(PamAccountType.Windows)).toBe(false);- expect(accountTypeSupportsSessionLogMasking(PamAccountType.WindowsAd)).toBe(false);+ // RDP recordings are base64 frames, and AWS IAM is gateway-less so it has no session log.+ const unmaskable = [PamAccountType.Windows, PamAccountType.WindowsAd, PamAccountType.AwsIam];++ test("is false for types with no maskable session log", () => {+ expect(unmaskable.every((type) => !accountTypeSupportsSessionLogMasking(type))).toBe(true);});test("is true for everything else", () => {- const rest = Object.values(PamAccountType).filter(- (type) => type !== PamAccountType.Windows && type !== PamAccountType.WindowsAd- );+ const rest = Object.values(PamAccountType).filter((type) => !unmaskable.includes(type));expect(rest.every(accountTypeSupportsSessionLogMasking)).toBe(true);});});diff --git a/frontend/src/hooks/api/pam/enums.ts b/frontend/src/hooks/api/pam/enums.tsindex deb2037077..666bdf9c1e 100644--- a/frontend/src/hooks/api/pam/enums.ts+++ b/frontend/src/hooks/api/pam/enums.ts@@ -46,12 +46,17 @@ export enum PamAccountWarning {SessionLogMaskingDegraded = "session-log-masking-degraded"}-// Brokered over RDP, whose recordings the gateway never masks. Mirrors-// accountTypeSupportsSessionLogMasking in backend/src/ee/services/pam/pam-enums.ts.-export const RDP_PAM_ACCOUNT_TYPES = [PamAccountType.Windows, PamAccountType.WindowsAd];+// Windows is brokered over RDP, whose recordings the gateway never masks; AWS IAM is gateway-less+// and produces no session log. Mirrors accountTypeSupportsSessionLogMasking in+// backend/src/ee/services/pam/pam-enums.ts.+export const UNMASKABLE_PAM_ACCOUNT_TYPES = [+ PamAccountType.Windows,+ PamAccountType.WindowsAd,+ PamAccountType.AwsIam+];export const pamAccountTypeSupportsSessionLogMasking = (type: PamAccountType | string) =>- !(RDP_PAM_ACCOUNT_TYPES as string[]).includes(type);+ !(UNMASKABLE_PAM_ACCOUNT_TYPES as string[]).includes(type);// Mirrors ORACLE_MAX_PASSWORD_LENGTH in backend/src/ee/services/pam-account/pam-account-schemas.ts, which is// what actually rejects a longer one. Change both together.diff --git a/frontend/src/pages/pam/components/AccountMaskingBadge.tsx b/frontend/src/pages/pam/components/AccountMaskingBadge.tsxindex 3bb7c6ea4f..7e1c4bbd89 100644--- a/frontend/src/pages/pam/components/AccountMaskingBadge.tsx+++ b/frontend/src/pages/pam/components/AccountMaskingBadge.tsx@@ -9,7 +9,7 @@ export const AccountMaskingBadge = ({ warnings }: { warnings: PamAccountWarning[return (<Tooltip><TooltipTrigger asChild>- <Badge variant="neutral">+ <Badge variant="warning"><AlertTriangle className="size-3" />Partial masking</Badge>