mirror of
https://github.com/DayuanJiang/next-ai-draw-io.git
synced 2026-01-02 14:22:28 +08:00
fix: prevent SSRF attack via custom base URL (GHSA-9qf7-mprq-9qgm)
Require API key when custom base URL is provided to prevent attackers from redirecting server API keys to malicious endpoints. CVSS: 9.3 (Critical)
This commit is contained in:
@@ -438,6 +438,16 @@ function validateProviderCredentials(provider: ProviderName): void {
|
|||||||
* - SILICONFLOW_BASE_URL: SiliconFlow endpoint (optional, defaults to https://api.siliconflow.com/v1)
|
* - SILICONFLOW_BASE_URL: SiliconFlow endpoint (optional, defaults to https://api.siliconflow.com/v1)
|
||||||
*/
|
*/
|
||||||
export function getAIModel(overrides?: ClientOverrides): ModelConfig {
|
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
|
// Check if client is providing their own provider override
|
||||||
const isClientOverride = !!(overrides?.provider && overrides?.apiKey)
|
const isClientOverride = !!(overrides?.provider && overrides?.apiKey)
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "next-ai-draw-io",
|
"name": "next-ai-draw-io",
|
||||||
"version": "0.4.1",
|
"version": "0.4.2",
|
||||||
"license": "Apache-2.0",
|
"license": "Apache-2.0",
|
||||||
"private": true,
|
"private": true,
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|||||||
Reference in New Issue
Block a user