Skip to content

Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.

fix(pam): handle AD-account access edge cases

bernie-g89de19a9c794
diff --git a/backend/src/ee/services/pam-account/pam-account-service.ts b/backend/src/ee/services/pam-account/pam-account-service.ts
index 61011d7d60..e82fd28b48 100644
--- a/backend/src/ee/services/pam-account/pam-account-service.ts
+++ b/backend/src/ee/services/pam-account/pam-account-service.ts
@@ -733,23 +733,30 @@ export const pamAccountServiceFactory = ({
throw new NotFoundError({ message: `Resource with name '${inputResourceName}' not found` });
}
- let account = await pamAccountDAL.findOne({
+ const localAccount = await pamAccountDAL.findOne({
projectId,
resourceId: resource.id,
name: inputAccountName
});
+ const domainAccount = resource.domainId
+ ? await pamAccountDAL.findOne({
+ projectId,
+ domainId: resource.domainId,
+ name: inputAccountName
+ })
+ : null;
- // Fall back to a domain account when the resource is joined to a domain.
- let isDomainAccount = false;
- if (!account && resource.domainId) {
- account = await pamAccountDAL.findOne({
- projectId,
- domainId: resource.domainId,
- name: inputAccountName
+ // Reject collisions explicitly: 'Administrator' commonly exists in both the
+ // local SAM and AD, and (resourceName, accountName) alone can't distinguish.
+ if (localAccount && domainAccount) {
+ throw new BadRequestError({
+ message: `Both a local and a domain account named '${inputAccountName}' exist on resource '${inputResourceName}'. Rename one to disambiguate.`
});
- if (account) isDomainAccount = true;
}
+ const account = localAccount ?? domainAccount;
+ const isDomainAccount = !localAccount && !!domainAccount;
+
if (!account) {
throw new NotFoundError({
message: `Account with name '${inputAccountName}' not found for resource '${inputResourceName}'`
diff --git a/frontend/src/pages/pam/PamAccountByIDPage/PamAccountByIDPage.tsx b/frontend/src/pages/pam/PamAccountByIDPage/PamAccountByIDPage.tsx
index ca4be24046..0795d2dafb 100644
--- a/frontend/src/pages/pam/PamAccountByIDPage/PamAccountByIDPage.tsx
+++ b/frontend/src/pages/pam/PamAccountByIDPage/PamAccountByIDPage.tsx
@@ -366,7 +366,25 @@ const PageContent = () => {
onOpenChange={(isOpen) => handlePopUpToggle("selectResource", isOpen)}
domainType={account.domain.domainType}
domainId={account.domain.id}
- onSelect={(resource) => {
+ onSelect={async (resource) => {
+ const { requiresApproval } = await checkPolicyMatch({
+ policyType: ApprovalPolicyType.PamAccess,
+ projectId: projectId!,
+ inputs: {
+ resourceName: resource.name,
+ accountName: account.name
+ }
+ });
+
+ if (requiresApproval) {
+ handlePopUpOpen("requestAccount", {
+ resourceName: resource.name,
+ accountName: account.name,
+ accountAccessed: true
+ });
+ return;
+ }
+
handlePopUpOpen("accessAccount", { account, resource });
}}
/>