Skip to content

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

Merge remote-tracking branch 'origin/main' into feat/PAM-184

Carlos Monastyrskicadaeea138b8
diff --cc backend/src/ee/services/pam-account/pam-account-service.ts
index cafb883925,13481fed25..245783e27d
--- a/backend/src/ee/services/pam-account/pam-account-service.ts
+++ b/backend/src/ee/services/pam-account/pam-account-service.ts
@@@ -790,22 -775,6 +792,19 @@@ export const pamAccountServiceFactory
);
}
+ // Reason check is intentionally placed after the approval/permission gates so
+ // its distinct error code does not leak policy configuration to unauthorized actors.
+ if (account.policyId) {
+ const policy = await pamAccountPolicyDAL.findById(account.policyId);
+ const policyRules = (policy?.rules ?? {}) as TPolicyRules;
+ if (policy?.isActive && policyRules[PamAccountPolicyRuleType.RequireReason] && !trimmedReason) {
+ throw new BadRequestError({
+ message: "A reason is required to access this account",
+ name: "PAM_REASON_REQUIRED"
+ });
+ }
+ }
+
- const project = await projectDAL.findById(account.projectId);
- if (!project) throw new NotFoundError({ message: `Project with ID '${account.projectId}' not found` });
-
const actorUser = await userDAL.findById(actor.id);
if (!actorUser) throw new NotFoundError({ message: `User with ID '${actor.id}' not found` });
diff --cc backend/src/ee/services/pam-web-access/pam-web-access-service.ts
index b148e7c57c,2f637f8680..489c26d0cc
--- a/backend/src/ee/services/pam-web-access/pam-web-access-service.ts
+++ b/backend/src/ee/services/pam-web-access/pam-web-access-service.ts
@@@ -250,22 -243,11 +252,24 @@@ export const pamWebAccessServiceFactor
);
}
+ // Reason check is intentionally placed after the approval/permission gates so
+ // its distinct error code does not leak policy configuration to unauthorized actors.
+ if (account.policyId) {
+ const policy = await pamAccountPolicyDAL.findById(account.policyId);
+ const policyRules = (policy?.rules ?? {}) as TPolicyRules;
+ if (policy?.isActive && policyRules[PamAccountPolicyRuleType.RequireReason] && !trimmedReason) {
+ throw new BadRequestError({
+ message: "A reason is required to access this account",
+ name: "PAM_REASON_REQUIRED"
+ });
+ }
+ }
+
// MFA check
if (account.requireMfa && !mfaSessionId) {
- const project = await projectDAL.findById(account.projectId);
+ const project = await requestMemoize(requestMemoKeys.projectFindById(account.projectId), () =>
+ projectDAL.findById(account.projectId)
+ );
if (!project) throw new NotFoundError({ message: `Project with ID '${account.projectId}' not found` });
const actorUser = await userDAL.findById(actor.id);