Skip to content

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

fix(pam): limit the CLI MFA handoff to CLI session launches

Carlos Monastyrskic3d5281df21f
diff --git a/backend/src/ee/services/pam-session/pam-session-service.ts b/backend/src/ee/services/pam-session/pam-session-service.ts
index 580007e367..ff3a8419dc 100644
--- a/backend/src/ee/services/pam-session/pam-session-service.ts
+++ b/backend/src/ee/services/pam-session/pam-session-service.ts
@@ -509,7 +509,8 @@ export const pamSessionServiceFactory = ({
actorEmail,
accountId: account.id,
mfaSessionId,
- tokenVersionId
+ tokenVersionId,
+ allowCliHandoff: accessMethod === PamAccessMethod.Cli
}
);
}
diff --git a/backend/src/ee/services/pam/pam-mfa.ts b/backend/src/ee/services/pam/pam-mfa.ts
index 97bca1f257..a89e01602b 100644
--- a/backend/src/ee/services/pam/pam-mfa.ts
+++ b/backend/src/ee/services/pam/pam-mfa.ts
@@ -23,7 +23,8 @@ export const enforceMfa = async (
actorEmail,
accountId,
mfaSessionId,
- tokenVersionId
+ tokenVersionId,
+ allowCliHandoff
}: {
userId: string;
orgId: string;
@@ -31,6 +32,7 @@ export const enforceMfa = async (
accountId: string;
mfaSessionId?: string;
tokenVersionId?: string;
+ allowCliHandoff?: boolean;
}
) => {
if (!mfaSessionId) {
@@ -47,7 +49,7 @@ export const enforceMfa = async (
accountId,
mfaMethod,
tokenVersionId,
- true
+ allowCliHandoff
);
if (mfaMethod === MfaMethod.EMAIL && actorEmail) {
diff --git a/backend/src/services/mfa-session/mfa-session-service.test.ts b/backend/src/services/mfa-session/mfa-session-service.test.ts
index 4b98196698..eab204dfbe 100644
--- a/backend/src/services/mfa-session/mfa-session-service.test.ts
+++ b/backend/src/services/mfa-session/mfa-session-service.test.ts
@@ -200,7 +200,15 @@ describe("mfaSessionService completing a challenge from another login session",
orgDAL: { findOrgById: vi.fn().mockResolvedValue({ enforceMfa: false }) } as never,
userDAL: { findById: vi.fn().mockResolvedValue({ isMfaEnabled: false }) } as never
},
- { userId: USER_ID, orgId: "org-1", actorEmail: "", accountId: ACCOUNT_ID, mfaSessionId, tokenVersionId }
+ {
+ userId: USER_ID,
+ orgId: "org-1",
+ actorEmail: "",
+ accountId: ACCOUNT_ID,
+ mfaSessionId,
+ tokenVersionId,
+ allowCliHandoff: true
+ }
);
const challenge = (await enforce(TOKEN_VERSION).catch((err: unknown) => err)) as BadRequestError;