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
feat(webauthn): enhance user credential response with FIPS mode status
Victor Hugo dos Santos2dac81e3ab39
diff --git a/backend/src/server/routes/v1/user-router.ts b/backend/src/server/routes/v1/user-router.tsindex ef64c309f1..a45aed39a6 100644--- a/backend/src/server/routes/v1/user-router.ts+++ b/backend/src/server/routes/v1/user-router.ts@@ -381,6 +381,7 @@ export const registerUserRouter = async (server: FastifyZodProvider) => {operationId: "getUserWebAuthnCredentials",response: {200: z.object({+ fipsEnabled: z.boolean(),credentials: z.array(z.object({id: z.string(),@@ -396,10 +397,9 @@ export const registerUserRouter = async (server: FastifyZodProvider) => {},onRequest: verifyAuth([AuthMode.JWT]),handler: async (req) => {- const credentials = await server.services.webAuthn.getUserWebAuthnCredentials({+ return server.services.webAuthn.getUserWebAuthnCredentials({userId: req.permission.id});- return { credentials };}});diff --git a/backend/src/server/routes/v2/mfa-router.ts b/backend/src/server/routes/v2/mfa-router.tsindex 9a2a663706..1a746e430f 100644--- a/backend/src/server/routes/v2/mfa-router.ts+++ b/backend/src/server/routes/v2/mfa-router.ts@@ -214,7 +214,7 @@ export const registerMfaRouter = async (server: FastifyZodProvider) => {},handler: async (req) => {try {- const credentials = await server.services.webAuthn.getUserWebAuthnCredentials({+ const { credentials } = await server.services.webAuthn.getUserWebAuthnCredentials({userId: req.mfa.userId});diff --git a/backend/src/services/webauthn/webauthn-service.ts b/backend/src/services/webauthn/webauthn-service.tsindex 234da5eda9..483cd987e2 100644--- a/backend/src/services/webauthn/webauthn-service.ts+++ b/backend/src/services/webauthn/webauthn-service.ts@@ -10,6 +10,7 @@ import {import { KeyStorePrefixes, KeyStoreTtls, TKeyStoreFactory } from "@app/keystore/keystore";import { getConfig } from "@app/lib/config/env";+import { crypto } from "@app/lib/crypto/cryptography";import { BadRequestError, ForbiddenRequestError, NotFoundError } from "@app/lib/errors";import { MfaMethod } from "../auth/auth-type";@@ -318,15 +319,18 @@ export const webAuthnServiceFactory = ({const getUserWebAuthnCredentials = async ({ userId }: TGetUserWebAuthnCredentialsDTO) => {const credentials = await webAuthnCredentialDAL.find({ userId });- // Don't return sensitive data like public keys- return credentials.map((cred) => ({- id: cred.id,- credentialId: cred.credentialId,- name: cred.name,- transports: cred.transports,- createdAt: cred.createdAt,- lastUsedAt: cred.lastUsedAt- }));+ return {+ fipsEnabled: crypto.isFipsModeEnabled(),+ // Don't return sensitive data like public keys+ credentials: credentials.map((cred) => ({+ id: cred.id,+ credentialId: cred.credentialId,+ name: cred.name,+ transports: cred.transports,+ createdAt: cred.createdAt,+ lastUsedAt: cred.lastUsedAt+ }))+ };};/**diff --git a/frontend/src/hooks/api/webauthn/queries.tsx b/frontend/src/hooks/api/webauthn/queries.tsxindex 60299a3fa7..0644801426 100644--- a/frontend/src/hooks/api/webauthn/queries.tsx+++ b/frontend/src/hooks/api/webauthn/queries.tsx@@ -2,7 +2,7 @@ import { useQuery } from "@tanstack/react-query";import { apiRequest } from "@app/config/request";-import { TWebAuthnCredential } from "./types";+import { TGetWebAuthnCredentialsResponse } from "./types";export const webAuthnKeys = {credentials: ["webauthn-credentials"] as const,@@ -14,9 +14,9 @@ export const useGetWebAuthnCredentials = () =>useQuery({queryKey: webAuthnKeys.credentials,queryFn: async () => {- const { data } = await apiRequest.get<{ credentials: TWebAuthnCredential[] }>(+ const { data } = await apiRequest.get<TGetWebAuthnCredentialsResponse>("/api/v1/user/me/webauthn");- return data.credentials;+ return data;}});diff --git a/frontend/src/hooks/api/webauthn/types.ts b/frontend/src/hooks/api/webauthn/types.tsindex f936790d39..048a2d689b 100644--- a/frontend/src/hooks/api/webauthn/types.ts+++ b/frontend/src/hooks/api/webauthn/types.ts@@ -14,6 +14,11 @@ export type TWebAuthnCredential = {lastUsedAt?: Date | null;};+export type TGetWebAuthnCredentialsResponse = {+ fipsEnabled: boolean;+ credentials: TWebAuthnCredential[];+};+export type TGenerateRegistrationOptionsResponse = PublicKeyCredentialCreationOptionsJSON;export type TVerifyRegistrationDTO = {diff --git a/frontend/src/pages/user/PersonalSettingsPage/components/SecuritySection/MFASection.tsx b/frontend/src/pages/user/PersonalSettingsPage/components/SecuritySection/MFASection.tsxindex 8987b8f145..690e44f2b6 100644--- a/frontend/src/pages/user/PersonalSettingsPage/components/SecuritySection/MFASection.tsx+++ b/frontend/src/pages/user/PersonalSettingsPage/components/SecuritySection/MFASection.tsx@@ -47,7 +47,8 @@ export const MFASection = () => {const { isBusy: isEnabling, enableMfa } = useEnableMfa();const { isBusy: isDisabling, disableMfa } = useDisableMfa();const { data: totpConfiguration } = useGetUserTotpConfiguration();- const { data: webAuthnCredentials = [] } = useGetWebAuthnCredentials();+ const { data: webAuthnData } = useGetWebAuthnCredentials();+ const webAuthnCredentials = webAuthnData?.credentials ?? [];const { data: organizations = [] } = useGetOrganizations();const { data: serverDetails } = useFetchServerStatus();diff --git a/frontend/src/pages/user/PersonalSettingsPage/components/SecuritySection/MfaMethodsCard.tsx b/frontend/src/pages/user/PersonalSettingsPage/components/SecuritySection/MfaMethodsCard.tsxindex 508f232ebe..63a6a75abc 100644--- a/frontend/src/pages/user/PersonalSettingsPage/components/SecuritySection/MfaMethodsCard.tsx+++ b/frontend/src/pages/user/PersonalSettingsPage/components/SecuritySection/MfaMethodsCard.tsx@@ -52,7 +52,8 @@ const MethodRow = ({ icon: Icon, title, description, badge, action }: MethodRowPexport const MfaMethodsCard = () => {const queryClient = useQueryClient();const { data: totpConfiguration } = useGetUserTotpConfiguration();- const { data: webAuthnCredentials = [] } = useGetWebAuthnCredentials();+ const { data: webAuthnData } = useGetWebAuthnCredentials();+ const webAuthnCredentials = webAuthnData?.credentials ?? [];const { data: serverDetails } = useFetchServerStatus();const { removeTotp, isBusy: isRemovingTotp } = useRemoveTotp();diff --git a/frontend/src/pages/user/PersonalSettingsPage/components/SecuritySection/PasskeyManagerDialog.tsx b/frontend/src/pages/user/PersonalSettingsPage/components/SecuritySection/PasskeyManagerDialog.tsxindex 5da2831e62..d35d37db18 100644--- a/frontend/src/pages/user/PersonalSettingsPage/components/SecuritySection/PasskeyManagerDialog.tsx+++ b/frontend/src/pages/user/PersonalSettingsPage/components/SecuritySection/PasskeyManagerDialog.tsx@@ -32,7 +32,8 @@ type Props = {};export const PasskeyManagerDialog = ({ isOpen, onOpenChange }: Props) => {- const { data: credentials = [], isPending } = useGetWebAuthnCredentials();+ const { data, isPending } = useGetWebAuthnCredentials();+ const credentials = data?.credentials ?? [];const { registerPasskey, isRegistering } = useRegisterPasskey();const { removePasskey, isBusy: isRemoving } = useRemovePasskey();@@ -48,15 +49,20 @@ export const PasskeyManagerDialog = ({ isOpen, onOpenChange }: Props) => {};// Hardware security keys registered before the server pinned ES256/RS256 may hold an- // EdDSA credential that some instances (FIPS mode) cannot verify at sign-in. We can't- // inspect the credential's algorithm client-side, so surface a soft notice whenever a- // security-key credential is present. Platform and phone passkeys always report- // "internal"/"hybrid" transports and are unaffected.- const hasSecurityKeyCredential = credentials.some(- (credential) =>- !credential.transports?.length ||- !credential.transports.some((transport) => transport === "internal" || transport === "hybrid")- );+ // EdDSA credential that FIPS instances cannot verify at sign-in. We can't inspect the+ // credential's algorithm client-side, so on FIPS instances surface a soft notice+ // whenever a security-key credential is present. Platform and phone passkeys always+ // report "internal"/"hybrid" transports and are unaffected, and non-FIPS instances+ // verify EdDSA fine.+ const hasSecurityKeyCredential =+ Boolean(data?.fipsEnabled) &&+ credentials.some(+ (credential) =>+ !credential.transports?.length ||+ !credential.transports.some(+ (transport) => transport === "internal" || transport === "hybrid"+ )+ );// Removing weakens a login second factor, so it goes through the step-up MFA// challenge; the confirm dialog stays open until the challenge completes and the