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-account): pass disambiguated identity to approval layer
bernie-g770933954da0
diff --git a/backend/src/ee/services/pam-account/pam-account-service.ts b/backend/src/ee/services/pam-account/pam-account-service.tsindex e4ee37e432..b8379045ac 100644--- a/backend/src/ee/services/pam-account/pam-account-service.ts+++ b/backend/src/ee/services/pam-account/pam-account-service.ts@@ -756,13 +756,20 @@ export const pamAccountServiceFactory = ({});}+ // Returns the account row plus the canonical identity to feed the approval+ // layer. For domain accounts we prefix with the FQDN from the domain row+ // (not the caller's hint) so casing is normalized and grants/policies+ // created against domain accounts can't be matched by a same-named local+ // grant (which would otherwise let one grant authorize both buckets).const lookupAccount = async () => {if (!isDomainAccount) {- return pamAccountDAL.findOne({+ const localAccount = await pamAccountDAL.findOne({projectId,resourceId: resource.id,name: accountSlug});+ if (!localAccount) return null;+ return { account: localAccount, accountIdentity: localAccount.name };}if (!resource.domainId) {throw new BadRequestError({@@ -783,19 +790,22 @@ export const pamAccountServiceFactory = ({message: `Resource '${inputResourceName}' is not joined to '${fqdnHint}'`});}- return pamAccountDAL.findOne({+ const domainAccount = await pamAccountDAL.findOne({projectId,domainId: resource.domainId,name: accountSlug});+ if (!domainAccount) return null;+ return { account: domainAccount, accountIdentity: `${domainConn.domain}:${domainAccount.name}` };};- const account = await lookupAccount();+ const lookup = await lookupAccount();- if (!account) {+ if (!lookup) {throw new NotFoundError({message: `Account with name '${inputAccountName}' not found for resource '${inputResourceName}'`});}+ const { account, accountIdentity } = lookup;const trimmedReason = reason?.trim() || null;@@ -804,7 +814,7 @@ export const pamAccountServiceFactory = ({const inputs = {resourceId: resource.id,resourceName: resource.name,- accountName: account.name+ accountName: accountIdentity};const canAccess = await fac.canAccess(approvalRequestGrantsDAL, resource.projectId, actor.id, inputs);diff --git a/frontend/src/pages/pam/PamAccountByIDPage/PamAccountByIDPage.tsx b/frontend/src/pages/pam/PamAccountByIDPage/PamAccountByIDPage.tsxindex dd9b833f44..ccc41524ed 100644--- a/frontend/src/pages/pam/PamAccountByIDPage/PamAccountByIDPage.tsx+++ b/frontend/src/pages/pam/PamAccountByIDPage/PamAccountByIDPage.tsx@@ -39,7 +39,7 @@ import {} from "@app/hooks/api/pam";import { useManualRotateAccount } from "@app/hooks/api/pam/mutations";import { pamKeys } from "@app/hooks/api/pam/queries";-import { PAM_DOMAIN_TYPE_MAP, PamDomainType } from "@app/hooks/api/pamDomain";+import { PAM_DOMAIN_TYPE_MAP, PamDomainType, useGetPamDomainById } from "@app/hooks/api/pamDomain";import { PamAccessAccountModal } from "../PamAccountsPage/components/PamAccessAccountModal";import { PamAwsIamAccessReasonModal } from "../PamAccountsPage/components/PamAwsIamAccessReasonModal";@@ -90,6 +90,15 @@ const PageContent = () => {const { data: account, isPending } = useGetPamAccountById(accountId);+ // Domain accounts use the AD FQDN to disambiguate from a like-named local+ // account. Fetch the full domain row for connectionDetails.domain so the+ // approval-layer identity matches what the backend computes.+ const { data: domain } = useGetPamDomainById(+ (account?.domain?.domainType as PamDomainType) ?? PamDomainType.ActiveDirectory,+ account?.domainId || undefined,+ { enabled: !!account?.domainId }+ );+if (isPending) {return <PageLoader />;}@@ -369,19 +378,25 @@ const PageContent = () => {domainType={account.domain.domainType}domainId={account.domain.id}onSelect={async (resource) => {+ // Domain accounts pass `<fqdn>:<slug>` to the approval layer so a+ // like-named local-account grant can't authorize this access.+ const accountIdentity = domain?.connectionDetails.domain+ ? `${domain.connectionDetails.domain}:${account.name}`+ : account.name;+const { requiresApproval, constraints } = await checkPolicyMatch({policyType: ApprovalPolicyType.PamAccess,projectId: projectId!,inputs: {resourceName: resource.name,- accountName: account.name+ accountName: accountIdentity}});if (requiresApproval) {handlePopUpOpen("requestAccount", {resourceName: resource.name,- accountName: account.name,+ accountName: accountIdentity,accountAccessed: true,accessDurationMax: constraints?.accessDuration.max});diff --git a/frontend/src/pages/pam/PamResourceByIDPage/components/PamResourceAccountsSection.tsx b/frontend/src/pages/pam/PamResourceByIDPage/components/PamResourceAccountsSection.tsxindex db285e7481..79328d1c3b 100644--- a/frontend/src/pages/pam/PamResourceByIDPage/components/PamResourceAccountsSection.tsx+++ b/frontend/src/pages/pam/PamResourceByIDPage/components/PamResourceAccountsSection.tsx@@ -256,19 +256,26 @@ export const PamResourceAccountsSection = ({ resource }: Props) => {};const accessAccount = async (account: TPamAccount) => {+ // Domain accounts pass `<fqdn>:<slug>` to the approval layer so a+ // like-named local-account grant can't authorize this access.+ const accountIdentity =+ account.domainId && domainData?.connectionDetails.domain+ ? `${domainData.connectionDetails.domain}:${account.name}`+ : account.name;+const { requiresApproval, constraints } = await checkPolicyMatch({policyType: ApprovalPolicyType.PamAccess,projectId: projectId!,inputs: {resourceName: resource.name,- accountName: account.name+ accountName: accountIdentity}});if (requiresApproval) {handlePopUpOpen("requestAccount", {resourceName: resource.name,- accountName: account.name,+ accountName: accountIdentity,accountAccessed: true,accessDurationMax: constraints?.accessDuration.max});