fix: validate vector store connection addresses against SSRF policy
Vector store create and raw connection-test accepted user-supplied connection addresses without SSRF validation, while every other admin-entered endpoint (e.g. model BaseURL) already runs ValidateURLForSSRF. An admin could point an engine address at an internal host and use the connection probe as an SSRF oracle. Add validateConnectionAddrSSRF, applied at the two user-input boundaries only: - CreateStore: validated before any network dial. - TestStoreRaw: a new TestRawConnection wrapper runs an engine-type allowlist, required-field validation, and SSRF validation before delegating to TestConnection. TestConnection stays validation-free for trusted callers (env stores, stored configs already validated at create time). Validation covers every address-bearing field a driver dials (Addr, qdrant Host+Port, weaviate Host and GrpcAddress) and fails closed for unmapped engine types. The Elasticsearch probe no longer follows redirects, closing a 302-to-internal bypass. docker-compose whitelists the bundled vector-store service hostnames (qdrant, milvus, weaviate, doris-fe) via SSRF_WHITELIST_EXTRA so the out-of-box experience is preserved; postgres is intentionally not whitelisted. .env.example and the OpenSearch dev guide document how to whitelist external or local-dev addresses.
This commit is contained in:
@@ -44,6 +44,20 @@ curl -s 'localhost:9200/_cat/plugins?format=json' | jq -r '.[].component' | grep
|
||||
|
||||
### Option A — DB store (UI / API)
|
||||
|
||||
> **SSRF whitelist (dev).** `CreateStore` and the raw connection test validate
|
||||
> the user-supplied `addr` against the SSRF policy. `http://localhost:9200`
|
||||
> is rejected by default — `localhost` is a restricted hostname and `9200` is
|
||||
> a blocked port. When the backend runs on the host (`go run`), add `localhost`
|
||||
> to the whitelist in your `.env` before registering:
|
||||
>
|
||||
> ```bash
|
||||
> SSRF_WHITELIST=localhost
|
||||
> ```
|
||||
>
|
||||
> The containerised compose deployment whitelists the bundled vector-store
|
||||
> service names automatically (`SSRF_WHITELIST_EXTRA`), so this step is
|
||||
> dev-only. The env-store path (Option B) is not affected.
|
||||
|
||||
`POST /api/v1/vector-stores`:
|
||||
|
||||
```json
|
||||
|
||||
Reference in New Issue
Block a user