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
address bot reviews
Andreycef7fd7482ff
diff --git a/backend/src/ee/routes/v1/pam-routers/pam-account-router.ts b/backend/src/ee/routes/v1/pam-routers/pam-account-router.tsindex 03cfd3aee5..4697f2044d 100644--- a/backend/src/ee/routes/v1/pam-routers/pam-account-router.ts+++ b/backend/src/ee/routes/v1/pam-routers/pam-account-router.ts@@ -805,6 +805,7 @@ export const registerPamAccountRouter = async (server: FastifyZodProvider) => {accountName: result.accountName,accountType: result.accountType,folderId: result.folderId,+ folderName: result.folderName,reason: result.reason,grantExpiresAt: result.grantExpiresAt?.toISOString() ?? null}diff --git a/backend/src/ee/services/audit-log/audit-log-types.ts b/backend/src/ee/services/audit-log/audit-log-types.tsindex 9a615b9096..6e9da22083 100644--- a/backend/src/ee/services/audit-log/audit-log-types.ts+++ b/backend/src/ee/services/audit-log/audit-log-types.ts@@ -6067,6 +6067,7 @@ interface PamAccountCredentialsViewEvent {accountName: string;accountType: string;folderId?: string | null;+ folderName?: string | null;reason?: string | null;grantExpiresAt?: string | null;};diff --git a/backend/src/ee/services/pam-access-request/pam-access-request-service.ts b/backend/src/ee/services/pam-access-request/pam-access-request-service.tsindex 2baff6db4a..b78222fa49 100644--- a/backend/src/ee/services/pam-access-request/pam-access-request-service.ts+++ b/backend/src/ee/services/pam-access-request/pam-access-request-service.ts@@ -45,6 +45,7 @@ import {import { ActorType } from "@app/services/auth/auth-type";import { TIdentityDALFactory } from "@app/services/identity/identity-dal";import { TKmsServiceFactory } from "@app/services/kms/kms-service";+import { KmsDataKey } from "@app/services/kms/kms-types";import { TMembershipDALFactory } from "@app/services/membership/membership-dal";import { TMembershipRoleDALFactory } from "@app/services/membership/membership-role-dal";import { TNotificationServiceFactory } from "@app/services/notification/notification-service";@@ -59,6 +60,7 @@ import { WorkflowIntegration } from "@app/services/workflow-integration/workflowimport {PamAccessStatus,PamAccessType,+ PamAccountType,PamNotificationEvent,PamProductRole,PamSessionStatus@@ -72,6 +74,11 @@ import {} from "../pam/pam-permission";import { resolveAccessControls } from "../pam/pam-policies";import { TPamAccountDALFactory } from "../pam-account/pam-account-dal";+import {+ hasRevealableCredential,+ noRevealableCredentialMessage,+ normalizeCredentialAuthMethod+} from "../pam-account/pam-account-schemas";import { TPamAccountTemplateDALFactory } from "../pam-account-template/pam-account-template-dal";import { TPamFolderDALFactory } from "../pam-folder/pam-folder-dal";import { TPamSessionDALFactory } from "../pam-session/pam-session-dal";@@ -677,6 +684,23 @@ export const pamAccessRequestServiceFactory = ({});}+ if (isCredentialRequest) {+ const { decryptor } = await kmsService.createCipherPairWithDataKey({+ type: KmsDataKey.SecretManager,+ projectId+ });+ const credentials = normalizeCredentialAuthMethod(+ account.accountType as PamAccountType,+ JSON.parse(decryptor({ cipherTextBlob: account.encryptedCredentials }).toString("utf-8")) as Record<+ string,+ unknown+ >+ );+ if (!hasRevealableCredential(account.accountType as PamAccountType, credentials)) {+ throw new BadRequestError({ message: noRevealableCredentialMessage(account.name) });+ }+ }+if (accessControls.requireReason && !trimmedReason) {throw new BadRequestError({name: "PAM_REASON_REQUIRED",diff --git a/backend/src/ee/services/pam-account/pam-account-schemas.ts b/backend/src/ee/services/pam-account/pam-account-schemas.tsindex fd9fdcc57d..2d4d344a87 100644--- a/backend/src/ee/services/pam-account/pam-account-schemas.ts+++ b/backend/src/ee/services/pam-account/pam-account-schemas.ts@@ -1331,8 +1331,23 @@ export const isCredentialConfigured = (});};-export const hasRetrievableCredentials = (accountType: PamAccountType): boolean => {+export const noRevealableCredentialMessage = (accountName: string) =>+ `Account '${accountName}' has no stored credential to reveal. Its authentication method brokers access per session instead.`;++export const hasRevealableCredential = (+ accountType: PamAccountType,+ rawCredentials?: Record<string, unknown>+): boolean => {const config = ACCOUNT_TYPE_CONFIGS[accountType as TSupportedAccountType];if (!config) return false;- return fieldsFromSchema(config.credentials, config.ui).some((field) => field.secret);++ const secretFields = fieldsFromSchema(config.credentials, config.ui).filter((field) => field.secret);+ if (!rawCredentials) return secretFields.length > 0;++ const credentials = normalizeCredentialAuthMethod(accountType, rawCredentials);+ return secretFields.some((field) => {+ if (field.showWhen && credentials[field.showWhen.field] !== field.showWhen.equals) return false;+ const value = credentials[field.key];+ return typeof value === "string" && value.trim().length > 0;+ });};diff --git a/backend/src/ee/services/pam-account/pam-account-service.ts b/backend/src/ee/services/pam-account/pam-account-service.tsindex 6cc4063f6c..14b1c4204d 100644--- a/backend/src/ee/services/pam-account/pam-account-service.ts+++ b/backend/src/ee/services/pam-account/pam-account-service.ts@@ -58,8 +58,9 @@ import { TPamAccountDALFactory } from "./pam-account-dal";import {applyForcedFields,getAccountAccessibilityIssues,- hasRetrievableCredentials,+ hasRevealableCredential,isCredentialConfigured,+ noRevealableCredentialMessage,normalizeCredentialAuthMethod,PamAccountAccessibilityIssue,parseInternalMetadata,@@ -299,7 +300,7 @@ export const pamAccountServiceFactory = (deps: TPamAccountServiceFactoryDep) =>isStale: a.isStale,requiresApproval,requiresCredentialApproval,- supportsCredentialReveal: hasRetrievableCredentials(a.accountType as PamAccountType),+ supportsCredentialReveal: hasRevealableCredential(a.accountType as PamAccountType),requireReason,accessStatus: requiresApproval ? (statusEntry?.accessStatus ?? PamAccessStatus.None) : PamAccessStatus.None,grantExpiresAt: statusEntry?.grantExpiresAt ?? null,@@ -384,12 +385,6 @@ export const pamAccountServiceFactory = (deps: TPamAccountServiceFactoryDep) =>);const accountType = account.accountType as PamAccountType;- if (!hasRetrievableCredentials(accountType)) {- throw new BadRequestError({- message: `Account '${account.name}' mints a short-lived credential per session and stores nothing to reveal`- });- }-const policy = resolveAccessControls(account.templatePolicies);const trimmedReason = reason?.trim() || null;@@ -445,10 +440,14 @@ export const pamAccountServiceFactory = (deps: TPamAccountServiceFactoryDep) =>accountType,await decrypt(projectId, account.encryptedCredentials));+ if (!hasRevealableCredential(accountType, credentials)) {+ throw new BadRequestError({ message: noRevealableCredentialMessage(account.name) });+ }return {accountId: account.id,accountName: account.name,+ folderName: account.folderName,accountType,folderId: account.folderId,credentials,diff --git a/frontend/src/pages/pam/PamAccountsPage/components/ViewCredentialsModal.tsx b/frontend/src/pages/pam/PamAccountsPage/components/ViewCredentialsModal.tsxindex 9c1907daa6..f3654b8aa3 100644--- a/frontend/src/pages/pam/PamAccountsPage/components/ViewCredentialsModal.tsx+++ b/frontend/src/pages/pam/PamAccountsPage/components/ViewCredentialsModal.tsx@@ -1,4 +1,4 @@-import { useEffect, useReducer, useState } from "react";+import { useEffect, useReducer, useRef, useState } from "react";import { ClipboardCheck, Copy, Eye, EyeOff, ShieldCheck } from "lucide-react";import {@@ -43,6 +43,12 @@ const errorMessageOf = (err: unknown) =>(err as { response?: { data?: { message?: string } } })?.response?.data?.message ??"Failed to reveal credentials. Please try again.";+const MFA_FAILURE_MESSAGE = {+ blocked:+ "Your browser blocked the MFA verification window. Allow popups for this site, then try again.",+ failed: "MFA verification timed out or failed. Please try again."+} as const;+const CredentialField = ({label,value,@@ -110,28 +116,34 @@ export const ViewCredentialsModal = ({const [errorMessage, setErrorMessage] = useState("");const [isVerifyingMfa, setIsVerifyingMfa] = useState(false);+ const openAccountId = useRef(accountId);+useEffect(() => {+ openAccountId.current = accountId;if (!isOpen) {setReason("");setCredentials(undefined);setErrorMessage("");setIsVerifyingMfa(false);}- }, [isOpen]);+ }, [isOpen, accountId]);+ // Recurses at most once: a retry already carrying an MFA session never re-enters the challengeconst reveal = async (mfaSessionId?: string) => {if (!accountId) return;+ const isStale = () => openAccountId.current !== accountId;setErrorMessage("");try {- setCredentials(- await fetchCredentials.mutateAsync({- accountId,- reason: reason.trim() || undefined,- mfaSessionId- })- );+ const revealed = await fetchCredentials.mutateAsync({+ accountId,+ reason: reason.trim() || undefined,+ mfaSessionId+ });+ if (!isStale()) setCredentials(revealed);} catch (err) {+ if (isStale()) return;+const challengeId = mfaSessionId ? undefined : extractMfaSessionId(err);if (!challengeId) {setErrorMessage(errorMessageOf(err));@@ -139,10 +151,12 @@ export const ViewCredentialsModal = ({}setIsVerifyingMfa(true);- const verified = await runMfaChallenge(challengeId);+ const outcome = await runMfaChallenge(challengeId);+ if (isStale()) return;+setIsVerifyingMfa(false);- if (verified) await reveal(challengeId);- else setErrorMessage("MFA verification timed out or failed. Please try again.");+ if (outcome === "verified") await reveal(challengeId);+ else setErrorMessage(MFA_FAILURE_MESSAGE[outcome]);}};diff --git a/frontend/src/pages/pam/components/useMfaChallenge.ts b/frontend/src/pages/pam/components/useMfaChallenge.tsindex c56a5c6f65..84ab07d59b 100644--- a/frontend/src/pages/pam/components/useMfaChallenge.ts+++ b/frontend/src/pages/pam/components/useMfaChallenge.ts@@ -22,15 +22,19 @@ export const extractMfaSessionId = (err: unknown): string | undefined => {return data?.error === "SESSION_MFA_REQUIRED" ? data.details?.mfaSessionId : undefined;};-// Opens the verification page in a popup and resolves once the session goes active, false otherwise+export type TMfaChallengeOutcome = "verified" | "blocked" | "failed";++// Opens the verification page in a popup and resolves once the session goes activeexport const useMfaChallenge = () => {const popupRef = useRef<Window | null>(null);- return useCallback(async (mfaSessionId: string) => {+ return useCallback(async (mfaSessionId: string): Promise<TMfaChallengeOutcome> => {popupRef.current = window.open(`${window.location.origin}/mfa-session/${mfaSessionId}`,"_blank");+ if (!popupRef.current) return "blocked";+const startTime = Date.now();const verified = await new Promise<boolean>((resolve) => {@@ -55,7 +59,7 @@ export const useMfaChallenge = () => {}, MFA_POLL_INTERVAL);});- if (popupRef.current && !popupRef.current.closed) popupRef.current.close();- return verified;+ if (!popupRef.current.closed) popupRef.current.close();+ return verified ? "verified" : "failed";}, []);};