Skip to content

Add PROXY_SERVER_ALLOWED_DB_ORIGINS to restrict proxy forwarding targets#1794

Open
kmcginnes wants to merge 2 commits into
mainfrom
proxy-server-allowed-db-origins
Open

Add PROXY_SERVER_ALLOWED_DB_ORIGINS to restrict proxy forwarding targets#1794
kmcginnes wants to merge 2 commits into
mainfrom
proxy-server-allowed-db-origins

Conversation

@kmcginnes
Copy link
Copy Markdown
Collaborator

@kmcginnes kmcginnes commented May 29, 2026

Description

Adds an optional PROXY_SERVER_ALLOWED_DB_ORIGINS env var that restricts which database origins the proxy server will forward requests to. When set (comma-separated origins like https://neptune:8182), the proxy rejects requests targeting unlisted origins with a 403. When unset, behavior is unchanged (fully permissive).

Also:

  • Introduces HttpError base class with optional details for structured error responses
  • Makes RequestValidationError extend HttpError (status 400, includes zodError in response)
  • Simplifies error handler — removes duck-typed getStatusFromError helper and the ...error spread
  • Disables HTTP redirects on all outbound fetch calls (redirect: "error")
  • Documents the new env var in docs/references/configuration.md and docs/references/security.md

Reading order: errors.tserror-handler.tsenv.tsallowed-db-origins.tsapp.ts (wiring) → docs

Validation

  • 224 tests pass across 12 test files in the proxy-server package
  • pnpm checks passes (lint, format, typecheck)
  • New unit tests for: HttpError hierarchy, env var parsing (valid/invalid/edge cases), assertAllowedDbOrigin function (case normalization, port normalization, scheme enforcement, empty set rejection)
  • New integration tests for: 403 enforcement across all 6 database routes, redirect disabled, no fetch call on rejection

Related Issues

Check List

  • I confirm that my contribution is made under the terms of the Apache 2.0 license.
  • I have verified pnpm checks passes with no errors.
  • I have verified pnpm test passes with no failures.
  • I have covered new added functionality with unit tests if necessary.
  • I have updated documentation if necessary.

Introduces an optional allowlist for database origins the proxy server
will forward to, mitigating SSRF risk. Also refactors error handling
with an HttpError base class and disables HTTP redirects on outbound
requests.
@kmcginnes kmcginnes marked this pull request as ready for review May 29, 2026 19:05
@kmcginnes kmcginnes force-pushed the proxy-server-allowed-db-origins branch from 3d31717 to 568fd0a Compare May 29, 2026 21:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add PROXY_SERVER_ALLOWED_DB_ORIGINS to restrict database URLs the proxy will forward to

2 participants