Enhanced ChatGPT Clone: Features Agents, MCP, Skills, DeepSeek, Anthropic, AWS, OpenAI, Responses API, Azure, Groq, o1, GPT-5, Mistral, OpenRouter, Vertex AI, Gemini, Artifacts, AI model switching, message search, Code Interpreter, langchain, DALL-E-3, OpenAPI Actions, Functions, Secure Multi-User Auth, Presets, open-source for self-hosting. Active
TypeScript aianthropicartifactsawsazurechatgptchatgpt-cloneclaudeclonedeepseekgeminigooglegpt-5librechatmcpo1openairesponses-apivisionwebui
🥫 fix: Refuse to Boot on Retired JWT Secret Defaults (#15282)
Danny Avila9423ad47cc4f
diff --git a/packages/api/src/credentials.spec.ts b/packages/api/src/credentials.spec.tsindex f67bea5def..180d57d24b 100644--- a/packages/api/src/credentials.spec.ts+++ b/packages/api/src/credentials.spec.ts@@ -122,6 +122,46 @@ describe('credentials', () => {expect(state.generated).toEqual(['CREDS_KEY', 'CREDS_IV']);});+ it.each([+ ['JWT_SECRET', '16f8c0ef4a5d391b26034086c628469d3f9f497f08163ab9b40137092f2909ef'],+ ['JWT_REFRESH_SECRET', 'eaa5191f2914e30b9387fd84e254e4ba6fc51b4654968a9b0803b456a54b8418'],+ ] as const)('rejects retired default %s values', (name, value) => {+ process.env[name] = value;++ expect(() => bootstrapCredentials()).toThrow(+ `[credentials] ${name} uses a retired default value. Configure a unique replacement before starting LibreChat.`,+ );+ });++ it.each([+ ['JWT_SECRET', '16f8c0ef4a5d391b26034086c628469d3f9f497f08163ab9b40137092f2909ef'],+ ['JWT_REFRESH_SECRET', 'eaa5191f2914e30b9387fd84e254e4ba6fc51b4654968a9b0803b456a54b8418'],+ ] as const)('rejects retired default %s values from temporary credentials', (name, value) => {+ fs.writeFileSync(tempFile, `${name}=${value}\n`);++ expect(() => bootstrapCredentials()).toThrow(+ `[credentials] ${name} uses a retired default value. Configure a unique replacement before starting LibreChat.`,+ );+ });++ it('rejects a retired default adopted from a concurrent temporary credential write', () => {+ fs.writeFileSync(tempFile, `CREDS_KEY=${'a'.repeat(64)}\nCREDS_IV=${'b'.repeat(32)}\n`);+ fs.writeFileSync(+ `${tempFile}.lock`,+ [+ `CREDS_KEY=${'a'.repeat(64)}`,+ `CREDS_IV=${'b'.repeat(32)}`,+ 'JWT_SECRET=16f8c0ef4a5d391b26034086c628469d3f9f497f08163ab9b40137092f2909ef',+ `JWT_REFRESH_SECRET=${'c'.repeat(64)}`,+ ].join('\n'),+ { mode: 0o600 },+ );++ expect(() => bootstrapCredentials()).toThrow(+ '[credentials] JWT_SECRET uses a retired default value. Configure a unique replacement before starting LibreChat.',+ );+ });+it('does not overwrite an explicitly selected environment file', () => {const environmentFile = path.join(tempDirectory, '.env');process.env.LIBRECHAT_TEMP_CREDENTIALS_PATH = environmentFile;diff --git a/packages/api/src/credentials.ts b/packages/api/src/credentials.tsindex b3bba9523f..2b2f0e261f 100644--- a/packages/api/src/credentials.ts+++ b/packages/api/src/credentials.ts@@ -11,7 +11,7 @@ export const credentialNames = [export type CredentialName = (typeof credentialNames)[number];-export type CredentialSource = 'environment' | 'temporary' | 'legacy-default';+export type CredentialSource = 'environment' | 'temporary';export interface CredentialRuntimeState {filePath: string;@@ -56,6 +56,18 @@ const legacyCredentialFingerprints: Partial<Record<CredentialName, string[]>> =JWT_REFRESH_SECRET: ['282ad5f60261639fefed381976b4d0dde52eab5527a1ab2ec75d5be1efa1165b'],};+const legacyJwtCredentialNames = new Set<CredentialName>(['JWT_SECRET', 'JWT_REFRESH_SECRET']);++function rejectLegacyJwtCredential(name: CredentialName, value: string): void {+ if (!legacyJwtCredentialNames.has(name) || !isLegacyCredential(name, value)) {+ return;+ }++ throw new Error(+ `[credentials] ${name} uses a retired default value. Configure a unique replacement before starting LibreChat.`,+ );+}+function getRuntimeState(): CredentialRuntimeState | undefined {const runtime = globalThis as typeof globalThis &Record<symbol, CredentialRuntimeState | undefined>;@@ -248,6 +260,8 @@ function adoptCredentialFile(if (!isUsableTemporaryCredential(name, value)) {return false;}++ rejectLegacyJwtCredential(name, value);}for (const name of names) {@@ -276,13 +290,15 @@ export function bootstrapCredentials(): CredentialRuntimeState {for (const name of credentialNames) {const environmentValue = process.env[name];if (isConfiguredCredential(environmentValue)) {- sources[name] = isLegacyCredential(name, environmentValue) ? 'legacy-default' : 'environment';+ rejectLegacyJwtCredential(name, environmentValue);+ sources[name] = 'environment';continue;}missingFromEnvironment.push(name);const fileValue = file.values[name];if (isUsableTemporaryCredential(name, fileValue)) {+ rejectLegacyJwtCredential(name, fileValue);process.env[name] = fileValue;sources[name] = 'temporary';loadedFromFile.push(name);