Never stop coding. Free MIT AI gateway: one endpoint, 375 providers (150+ free), 1,400+ models Kimi, Claude, GPT, Gemini, GLM, DeepSeek, MiniMax. Works with Claude Code, Codex, Cursor, OpenCode, Cline & Copilot. Quota-aware auto-fallback, RTK+Caveman compression saves 15-95% tokens, MCP/A2A, Desktop/PWA. Built by 900+ contributors
TypeScript a2aai-agentsai-gatewayanthropicclaudeclaude-codeclinecodexcopilotcursordeepseekfree-aigeminikimillm-gatewaymcpopenaiopenai-proxyqwentoken-saver
fix(db): enforce stricter validation for api key model access
nyatoru7ed40c2139c4
diff --git a/src/lib/db/apiKeys.ts b/src/lib/db/apiKeys.tsindex 20acee77d2..8bde82bc9a 100644--- a/src/lib/db/apiKeys.ts+++ b/src/lib/db/apiKeys.ts@@ -291,7 +291,10 @@ export async function getApiKeyMetadata(key) {* @returns {boolean} - true if allowed, false if not*/export async function isModelAllowedForKey(key, modelId) {- if (!key || !modelId) return true; // No key or model = allow (backward compatibility)+ // If no key provided, allow (request may be using different auth method like JWT)+ // If no modelId provided, deny (invalid request)+ if (!key) return true;+ if (!modelId) return false;// Create cache keyconst cacheKey = `${key}:${modelId}`;@@ -304,7 +307,8 @@ export async function isModelAllowedForKey(key, modelId) {}const metadata = await getApiKeyMetadata(key);- if (!metadata) return true; // Key not found = allow (backward compatibility)+ // SECURITY: Key not found in database = deny access (invalid/non-existent key)+ if (!metadata) return false;const { allowedModels } = metadata;