From 62e4fb47b21aa601703c24c55335f3ea24d249c8 Mon Sep 17 00:00:00 2001 From: amodev <100158968+amodevinc@users.noreply.github.com> Date: Wed, 1 May 2024 15:01:48 +0900 Subject: [PATCH] Fix API key exposure in toast notifications, resolves #1477 (#1480) --- frontend/src/components/modals/settings/SettingsModal.tsx | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/frontend/src/components/modals/settings/SettingsModal.tsx b/frontend/src/components/modals/settings/SettingsModal.tsx index d3e636c142..cf815a7f05 100644 --- a/frontend/src/components/modals/settings/SettingsModal.tsx +++ b/frontend/src/components/modals/settings/SettingsModal.tsx @@ -76,8 +76,14 @@ function SettingsModal({ isOpen, onOpenChange }: SettingsProps) { i18next.changeLanguage(settings.LANGUAGE); initializeAgent(settings); // reinitialize the agent with the new settings + const sensitiveKeys = ['LLM_API_KEY']; + Object.entries(updatedSettings).forEach(([key, value]) => { - toast.settingsChanged(`${key} set to "${value}"`); + if (!sensitiveKeys.includes(key)) { + toast.settingsChanged(`${key} set to "${value}"`); + } else { + toast.settingsChanged(`${key} has been updated securely.`); + } }); localStorage.setItem(