Skip to content

fix(ssrf): add ALLOW_LOCAL_NETWORKS env var for self-hosted deployments#366

Merged
cosarah merged 2 commits intomainfrom
worktree-357-allow-local-networks
Apr 7, 2026
Merged

fix(ssrf): add ALLOW_LOCAL_NETWORKS env var for self-hosted deployments#366
cosarah merged 2 commits intomainfrom
worktree-357-allow-local-networks

Conversation

@wyuc
Copy link
Copy Markdown
Contributor

@wyuc wyuc commented Apr 4, 2026

Summary

  • Add ALLOW_LOCAL_NETWORKS env var that bypasses private-IP checks in the SSRF guard, allowing self-hosted users to use local endpoints (Ollama, local TTS/ASR, etc.)
  • Protocol validation (HTTP/HTTPS only) is still enforced regardless of this setting
  • Document the env var in .env.example

Test plan

  • Without env var: private network URLs blocked (localhost, 192.168.x.x, 10.x.x.x, 172.16.x.x)
  • With ALLOW_LOCAL_NETWORKS=true: private network URLs allowed
  • Both modes: non-HTTP(S) URLs still blocked (ftp://, etc.)
  • Both modes: public URLs (api.openai.com) work normally
  • pnpm check / pnpm lint / tsc --noEmit pass
  • Dev server manual smoke test pass

Fixes #310, fixes #311
Partial fix for #357

Self-hosted users need to access local network services (Ollama, local
TTS/ASR endpoints, etc.) but the SSRF guard blocks all private addresses.
Add ALLOW_LOCAL_NETWORKS env var that skips private-IP checks when set
to "true" or "1", while still validating URL format and protocol.

Fixes #310
Fixes #311

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Copy link
Copy Markdown
Collaborator

@cosarah cosarah left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Clean, minimal change that solves a real pain point for self-hosted deployments. Protocol validation stays enforced, private-IP bypass is explicitly opt-in and well-documented.

Verified locally — Ollama/llama.cpp on a local network endpoint works correctly with ALLOW_LOCAL_NETWORKS=true.

Minor suggestions (non-blocking)

  • lib/server/ssrf-guard.ts:33 — Consider .trim().toLowerCase() on the env value so True, TRUE, or accidental whitespace also work.

LGTM.

@cosarah cosarah merged commit 7474290 into main Apr 7, 2026
3 checks passed
jaumemir pushed a commit to jaumemir/OpenMAIC that referenced this pull request Apr 11, 2026
…ts (THU-MAIC#366)

Self-hosted users need to access local network services (Ollama, local
TTS/ASR endpoints, etc.) but the SSRF guard blocks all private addresses.
Add ALLOW_LOCAL_NETWORKS env var that skips private-IP checks when set
to "true" or "1", while still validating URL format and protocol.

Fixes THU-MAIC#310
Fixes THU-MAIC#311

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-authored-by: 杨慎 <117187635+cosarah@users.noreply.github.com>
gulmarkhan-opc pushed a commit to tajwali/OpenMAIC that referenced this pull request Apr 18, 2026
…ts (THU-MAIC#366)

Self-hosted users need to access local network services (Ollama, local
TTS/ASR endpoints, etc.) but the SSRF guard blocks all private addresses.
Add ALLOW_LOCAL_NETWORKS env var that skips private-IP checks when set
to "true" or "1", while still validating URL format and protocol.

Fixes THU-MAIC#310
Fixes THU-MAIC#311

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-authored-by: 杨慎 <117187635+cosarah@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants