Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS
JavaScript ai-agentsdashboarddeveloper-toolsdigital-twinquantified-selfsecond-brainself-hostedtailscale
address review (codex): allowlist bundled NVIDIA NIM host and guard keyed lmstudio voice provider
[._.]/ Adam Eivya77d039e8d89
diff --git a/server/lib/aiToolkit/internal/endpointGuard.js b/server/lib/aiToolkit/internal/endpointGuard.jsindex ca059d9034..76f4047686 100644--- a/server/lib/aiToolkit/internal/endpointGuard.js+++ b/server/lib/aiToolkit/internal/endpointGuard.js@@ -63,6 +63,7 @@ const ALLOWED_PROVIDER_HOSTS = new Set(['api.cohere.com','api.fireworks.ai','api.cerebras.ai',+ 'integrate.api.nvidia.com', // NVIDIA NIM (bundled `nvidia-kimi` provider)]);const IPV4_RE = /^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/;diff --git a/server/lib/aiToolkit/internal/endpointGuard.test.js b/server/lib/aiToolkit/internal/endpointGuard.test.jsindex 77aecd55f1..3784b0b0b8 100644--- a/server/lib/aiToolkit/internal/endpointGuard.test.js+++ b/server/lib/aiToolkit/internal/endpointGuard.test.js@@ -81,6 +81,9 @@ describe('endpointGuard — evaluateSecretEndpoint', () => {it('allows generativelanguage.googleapis.com', () => {expect(evaluateSecretEndpoint('https://generativelanguage.googleapis.com/v1beta').allowed).toBe(true);});+ it('allows the bundled NVIDIA NIM host without opt-in', () => {+ expect(evaluateSecretEndpoint('https://integrate.api.nvidia.com/v1').allowed).toBe(true);+ });});describe('arbitrary public hosts require explicit opt-in', () => {diff --git a/server/services/voice/llm.js b/server/services/voice/llm.jsindex 55ad82cc5f..51274ed04d 100644--- a/server/services/voice/llm.js+++ b/server/services/voice/llm.js@@ -27,17 +27,18 @@ export const resolveLlmEndpoint = async (providerId = 'lmstudio') => {// working without re-saving the provider endpoint.const useEnv = provider.id === 'lmstudio' && process.env.LM_STUDIO_URL;const apiBase = (useEnv ? LM_STUDIO_API_BASE() : provider.endpoint).replace(/\/+$/, '');- // Guard non-built-in providers before attaching their API key to the- // /models and /chat/completions fetches below — a hostile/mistyped- // endpoint could otherwise harvest a paid LLM key or reach a- // cloud-metadata service (SSRF). The built-in local `lmstudio` provider is- // exempt: it's the trusted local-LLM fallback and normally carries no key.- if (provider.id !== 'lmstudio') {- assertSecretEndpoint(apiBase, {- hasSecret: Boolean(provider.apiKey),- allowCustomEndpoint: provider.allowCustomEndpoint === true,- });- }+ // Guard before attaching the provider's API key to the /models and+ // /chat/completions fetches below — a hostile/mistyped endpoint could+ // otherwise harvest a paid LLM key or reach a cloud-metadata service+ // (SSRF). This no-ops when no key is attached, so the built-in local+ // `lmstudio`/`ollama` fallbacks (normally keyless) are unaffected at any+ // host; only a key-bearing request to a metadata / non-allowlisted host is+ // blocked — keeping this path consistent with askService and+ // localLlmPlayground, which never exempted lmstudio.+ assertSecretEndpoint(apiBase, {+ hasSecret: Boolean(provider.apiKey),+ allowCustomEndpoint: provider.allowCustomEndpoint === true,+ });return {apiBase,apiKey: provider.apiKey || '',diff --git a/server/services/voice/llm.test.js b/server/services/voice/llm.test.jsindex 764b573768..a89a970d78 100644--- a/server/services/voice/llm.test.js+++ b/server/services/voice/llm.test.js@@ -202,7 +202,6 @@ describe('resolveLlmEndpoint', () => {getProviderById.mockResolvedValue({id: 'nvidia-kimi', type: 'api', endpoint: 'https://integrate.api.nvidia.com/v1',apiKey: 'secret', defaultModel: 'moonshotai/kimi-k2-5', name: 'NVIDIA Kimi',- allowCustomEndpoint: true,});const ep = await resolveLlmEndpoint('nvidia-kimi');expect(ep.apiBase).toBe('https://integrate.api.nvidia.com/v1');@@ -239,6 +238,21 @@ describe('resolveLlmEndpoint', () => {expect(ep.apiBase).toBe('http://10.0.0.5:1234/v1');});+ it('blocks a key-bearing lmstudio provider pointed at a cloud-metadata host', async () => {+ getProviderById.mockResolvedValue({+ id: 'lmstudio', type: 'api', endpoint: 'http://169.254.169.254/v1', apiKey: 'leaked',+ });+ await expect(resolveLlmEndpoint('lmstudio')).rejects.toThrow(/Blocked outbound API-key request/);+ });++ it('allows a keyless lmstudio provider at any host (guard no-ops without a key)', async () => {+ getProviderById.mockResolvedValue({+ id: 'lmstudio', type: 'api', endpoint: 'http://192.0.2.10:1234/v1', apiKey: '',+ });+ const ep = await resolveLlmEndpoint('lmstudio');+ expect(ep.apiBase).toBe('http://192.0.2.10:1234/v1');+ });+it('does NOT apply the env override to non-lmstudio providers', async () => {process.env.LM_STUDIO_URL = 'http://10.0.0.5:1234';getProviderById.mockResolvedValue({ id: 'ollama', type: 'api', endpoint: 'http://localhost:11434/v1', apiKey: '' });