diff --git a/lib/ai-providers.ts b/lib/ai-providers.ts index 875888f..3a3b83d 100644 --- a/lib/ai-providers.ts +++ b/lib/ai-providers.ts @@ -438,6 +438,16 @@ function validateProviderCredentials(provider: ProviderName): void { * - SILICONFLOW_BASE_URL: SiliconFlow endpoint (optional, defaults to https://api.siliconflow.com/v1) */ export function getAIModel(overrides?: ClientOverrides): ModelConfig { + // SECURITY: Prevent SSRF attacks (GHSA-9qf7-mprq-9qgm) + // If a custom baseUrl is provided, an API key MUST also be provided. + // This prevents attackers from redirecting server API keys to malicious endpoints. + if (overrides?.baseUrl && !overrides?.apiKey) { + throw new Error( + `API key is required when using a custom base URL. ` + + `Please provide your own API key in Settings.`, + ) + } + // Check if client is providing their own provider override const isClientOverride = !!(overrides?.provider && overrides?.apiKey) diff --git a/package.json b/package.json index eb41e7e..1e9e48e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "next-ai-draw-io", - "version": "0.4.1", + "version": "0.4.2", "license": "Apache-2.0", "private": true, "scripts": {