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 misc comments
Andrey0f07a213bc41
diff --git a/backend/src/ee/services/pam-access-request/pam-access-approval-resource.ts b/backend/src/ee/services/pam-access-request/pam-access-approval-resource.tsindex 33d70084d1..da219a9e18 100644--- a/backend/src/ee/services/pam-access-request/pam-access-approval-resource.ts+++ b/backend/src/ee/services/pam-access-request/pam-access-approval-resource.ts@@ -88,7 +88,7 @@ type TPamAccessApprovalResourceDep = {userGroupMembershipDAL: Pick<TUserGroupMembershipDALFactory, "findGroupMembershipsByUserIdInOrg">;approvalRequestDAL: Pick<TApprovalRequestDALFactory, "find">;approvalRequestGrantsDAL: Pick<TApprovalRequestGrantsDALFactory, "find" | "create" | "updateById">;- pamAccountDAL: Pick<TPamAccountDALFactory, "findByIdWithDetails" | "find">;+ pamAccountDAL: Pick<TPamAccountDALFactory, "findByIdWithDetails" | "findTemplatePoliciesForShare" | "find">;pamAccountTemplateDAL: Pick<TPamAccountTemplateDALFactory, "find">;pamFolderDAL: Pick<TPamFolderDALFactory, "findById" | "find">;pamSessionDAL: Pick<TPamSessionDALFactory, "find" | "update">;@@ -461,7 +461,7 @@ export const pamAccessApprovalResourceFactory = ({const policySteps = await approvalPolicyDAL.findStepsByPolicyId(policy.id);// A folder with rules and no approvers grants access only through its rules- const isRulesOnly = policySteps.length === 0 && hasAutoApprovalRules;+ const isRulesOnly = !policySteps.some((step) => step.approvers.length > 0) && hasAutoApprovalRules;if (!isRulesOnly && (policySteps.length === 0 || policySteps.some((step) => step.approvers.length === 0))) {throw new BadRequestError({message:@@ -503,12 +503,15 @@ export const pamAccessApprovalResourceFactory = ({// The account's template opts it in with Allow Auto-Approvalconst allowsAutoApproval: NonNullable<TPamAccessApprovalResource["allowsAutoApproval"]> = async ({projectId,- requestData+ requestData,+ tx}) => {const { accountId } = requestData as { accountId?: string };if (!accountId) return false;- const account = await pamAccountDAL.findByIdWithDetails(accountId);+ const account = tx+ ? await pamAccountDAL.findTemplatePoliciesForShare(accountId, tx)+ : await pamAccountDAL.findByIdWithDetails(accountId);if (!account || account.projectId !== projectId) return false;return resolveAccessControls(account.templatePolicies).allowAutoApproval;diff --git a/backend/src/ee/services/pam-account/pam-account-dal.ts b/backend/src/ee/services/pam-account/pam-account-dal.tsindex 05aa423dee..c64f610be7 100644--- a/backend/src/ee/services/pam-account/pam-account-dal.ts+++ b/backend/src/ee/services/pam-account/pam-account-dal.ts@@ -252,6 +252,16 @@ export const pamAccountDALFactory = (db: TDbClient) => {return rows[0] || null;};+ // Locks the account and its template, so neither changes before the caller's transaction commits+ const findTemplatePoliciesForShare = async (accountId: string, tx: Knex) =>+ (await tx(TableName.PamAccount)+ .join(TableName.PamAccountTemplate, `${TableName.PamAccount}.templateId`, `${TableName.PamAccountTemplate}.id`)+ .where(`${TableName.PamAccount}.id`, accountId)+ .forShare(TableName.PamAccount, TableName.PamAccountTemplate)+ .first(`${TableName.PamAccount}.projectId`, `${TableName.PamAccountTemplate}.policies as templatePolicies`)) as+ | { projectId: string; templatePolicies: unknown }+ | undefined;+const findByIdsWithDetails = async (accountIds: string[],accountType: string,@@ -534,6 +544,7 @@ export const pamAccountDALFactory = (db: TDbClient) => {countByGatewayIds,findAccessible,findByIdWithDetails,+ findTemplatePoliciesForShare,findByIdsWithDetails,findAccountsToRotate,countAccountsToRotate,diff --git a/backend/src/ee/services/pam-account/pam-account-service.ts b/backend/src/ee/services/pam-account/pam-account-service.tsindex 845627a734..ca8e5a49c8 100644--- a/backend/src/ee/services/pam-account/pam-account-service.ts+++ b/backend/src/ee/services/pam-account/pam-account-service.ts@@ -406,7 +406,14 @@ export const pamAccountServiceFactory = (deps: TPamAccountServiceFactoryDep) =>const { requiresApproval, requireReason, allowBreakGlass, allowAutoApproval } = resolveAccessControls(a.templatePolicies);- if (requiresApproval && a.folderId && !foldersWithApprovalPolicy.isConfiguredFor(a.folderId, allowAutoApproval)) {+ const canBreakGlass = allowBreakGlass && !!a.folderId && breakGlassFolders.has(a.folderId);+ // Break-glass users can still reach a folder whose approvers and rules can't grant this account+ if (+ requiresApproval &&+ a.folderId &&+ !canBreakGlass &&+ !foldersWithApprovalPolicy.isConfiguredFor(a.folderId, allowAutoApproval)+ ) {accessibilityIssues.push(PamAccountAccessibilityIssue.NoApprovalConfig);}const statusEntry = accessStatusMap.get(a.id);@@ -438,7 +445,7 @@ export const pamAccountServiceFactory = (deps: TPamAccountServiceFactoryDep) =>: ApprovalAccessStatus.None,grantExpiresAt: statusEntry?.grantExpiresAt ?? null,pendingRequestId: statusEntry?.pendingRequestId ?? null,- canBreakGlass: allowBreakGlass && !!a.folderId && breakGlassFolders.has(a.folderId),+ canBreakGlass,credentialAccessStatus: requiresApproval? (credentialStatusEntry?.accessStatus ?? ApprovalAccessStatus.None): ApprovalAccessStatus.None,@@ -1328,8 +1335,9 @@ export const pamAccountServiceFactory = (deps: TPamAccountServiceFactoryDep) =>const { requiresApproval, requireReason, requireMfa, allowBreakGlass, allowAutoApproval } =resolveAccessControls(a.templatePolicies);const statusEntry = accessStatusMap.get(a.id);+ const canBreakGlass = allowBreakGlass && !!a.folderId && breakGlassFolders.has(a.folderId);const hasPolicyConfigured = a.folderId- ? foldersWithApprovalPolicy.isConfiguredFor(a.folderId, allowAutoApproval)+ ? canBreakGlass || foldersWithApprovalPolicy.isConfiguredFor(a.folderId, allowAutoApproval): false;let disabledReason: string | null = null;if (requiresApproval && !hasPolicyConfigured) {@@ -1357,7 +1365,7 @@ export const pamAccountServiceFactory = (deps: TPamAccountServiceFactoryDep) =>: ApprovalAccessStatus.None,grantExpiresAt: statusEntry?.grantExpiresAt ?? null,pendingRequestId: statusEntry?.pendingRequestId ?? null,- canBreakGlass: allowBreakGlass && !!a.folderId && breakGlassFolders.has(a.folderId),+ canBreakGlass,disabledReason,createdAt: a.createdAt,updatedAt: a.updatedAtdiff --git a/backend/src/services/approval-policy/approval-policy-service.ts b/backend/src/services/approval-policy/approval-policy-service.tsindex d9103831a8..1f5d94c500 100644--- a/backend/src/services/approval-policy/approval-policy-service.ts+++ b/backend/src/services/approval-policy/approval-policy-service.ts@@ -1191,6 +1191,14 @@ export const approvalPolicyServiceFactory = ({message: "The auto-approval rules changed while this request was being checked. Submit it again."});}+ const stillAllowed =+ (await resource.allowsAutoApproval?.({ projectId, requestData: requestData as TApprovalRequestData, tx })) ??+ true;+ if (!stillAllowed) {+ throw new BadRequestError({+ message: "Auto-approval was turned off for this request while it was being checked. Submit it again."+ });+ }await $claimUnusedRecords(policy.id, evidence, tx);const created = await createApprovalRequestWithSteps(diff --git a/backend/src/services/approval-policy/approval-policy-types.ts b/backend/src/services/approval-policy/approval-policy-types.tsindex 114106c12d..30032f193d 100644--- a/backend/src/services/approval-policy/approval-policy-types.ts+++ b/backend/src/services/approval-policy/approval-policy-types.ts@@ -219,6 +219,7 @@ export type TApprovalResource<allowsAutoApproval?: (args: {projectId: string;requestData: TApprovalRequestData | TApprovalPolicyInputs;+ tx?: Knex;}) => Promise<boolean>;postRejectionRoutine?: (request: TApprovalRequest) => Promise<void>;diff --git a/frontend/src/pages/pam/components/RequestAccessSheet.tsx b/frontend/src/pages/pam/components/RequestAccessSheet.tsxindex e07148e085..2f22117879 100644--- a/frontend/src/pages/pam/components/RequestAccessSheet.tsx+++ b/frontend/src/pages/pam/components/RequestAccessSheet.tsx@@ -200,7 +200,16 @@ export const RequestAccessSheet = ({: account?.pendingRequestId;const canBreakGlass = Boolean(account?.canBreakGlass && pendingRequestId);const requireReason = Boolean(account?.requireReason);- const [breakGlassOnSubmit, setBreakGlassOnSubmit] = useState(false);+ const { data: approverData } = useGetPamAccountApprovers(account?.id, accessType);+ // With no approvers and no auto-approval rules that apply, break glass is the only way in+ const isBreakGlassOnly = Boolean(+ account?.canBreakGlass &&+ approverData &&+ !approverData.autoApprovalOnly &&+ !approverData.steps.some((step) => step.approvers.length > 0)+ );+ const [breakGlassChosen, setBreakGlassChosen] = useState(false);+ const breakGlassOnSubmit = breakGlassChosen || isBreakGlassOnly;const requestLabel = isCredentialRequest ? "Request credentials" : "Request session access";const submitLabel = breakGlassOnSubmit ? "Break glass" : requestLabel;const schema = useMemo(@@ -218,7 +227,6 @@ export const RequestAccessSheet = ({defaultValues: { duration: "1h", reason: "" }});- const { data: approverData } = useGetPamAccountApprovers(account?.id, accessType);const autoApprovalInputDetails = approverData?.autoApprovalInputs ?? [];const hasAutoApprovalValues = Object.values(autoApprovalValues).some((value) => value.trim());@@ -226,7 +234,7 @@ export const RequestAccessSheet = ({if (!open) {reset();setBypassReason("");- setBreakGlassOnSubmit(false);+ setBreakGlassChosen(false);setAutoApprovalValues({});}onOpenChange(open);@@ -531,13 +539,16 @@ export const RequestAccessSheet = ({Break glass</FieldTitle><FieldDescription>- Grant now, skipping the approvers. Every use is audited.+ {isBreakGlassOnly+ ? "Required here. The folder has no approvers. Auto-approval is off for this account. Every use is audited."+ : "Grant now, skipping the approvers. Every use is audited."}</FieldDescription></FieldContent><Togglechecked={breakGlassOnSubmit}variant="danger"- onCheckedChange={setBreakGlassOnSubmit}+ disabled={isBreakGlassOnly}+ onCheckedChange={setBreakGlassChosen}/></Field></Card>