Persistent SSRF allowlist + admin UI + test fix hint (#2)#166
Merged
Conversation
Before this, SSRF_ALLOWED_HOSTS could only be set as a backend env var.
Deploying a new connector against a service on the internal network
(e.g. a docker-compose sibling like 'koch-filesystem-bridge') required
editing the env, restarting the container, and praying.
Now:
- New SsrfPolicyService merges the env var with a DB-backed list
stored in SiteSettings ('ssrf_allowed_hosts' key, JSON array). The
list is cached in-process for 60s and re-read after each write
through invalidate().
- ssrf.util.ts exposes setDbAllowedHostsProvider(); the policy service
wires itself in via onModuleInit so every assertSafeOutboundUrl call
consults both layers. No-op if the service isn't loaded (unit tests).
- New admin API: GET / PUT /api/admin/settings/ssrf-allowed-hosts.
PUT validates host shape (no URLs, no whitespace, allows hostnames,
*.suffix wildcards, and bare IPs).
- Frontend admin settings page: new 'SSRF allowlist' section with a
red warning, the env-var list shown read-only, and a textarea for
the admin-editable list.
- Connector test response carries a suggestedFix:
{ action: 'add-to-ssrf-allowlist', hostname, url }
when the failure was the SSRF guard rejecting an internal hostname.
The connector detail UI renders this as a click-through to
/admin/settings#ssrf.
Tests: SsrfPolicyService spec (7 cases). Full backend suite green
(631 passed). Frontend tsc clean.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
`SSRF_ALLOWED_HOSTS` was a backend env var only. Onboarding a connector that calls a service on the internal network — e.g. a docker-compose sibling like `koch-filesystem-bridge` (a real customer case) — required editing the env, restarting, and there was nothing in the UI explaining the failure or how to fix it.
Changes
Backend
```json
{ "action": "add-to-ssrf-allowlist", "hostname": "koch-filesystem-bridge", "url": "/admin/settings#ssrf" }
```
Frontend
Security notes
Test plan