Skip to content

fix(security): harden proxy x-base-url against key leak and SSRF - #6884

Open
BetterAndBetterII wants to merge 1 commit into
ChatGPTNextWeb:mainfrom
BetterAndBetterII:fix/6814-proxy-key-ssrf
Open

BetterAndBetterII wants to merge 1 commit into
ChatGPTNextWeb:mainfrom
BetterAndBetterII:fix/6814-proxy-key-ssrf

Conversation

@BetterAndBetterII

Copy link
Copy Markdown

Summary

  • Inject the server OPENAI_API_KEY only when the parsed x-base-url hostname is exactly api.openai.com (not a query/path/fragment/userinfo substring).
  • Reject non-http(s) x-base-url values and private/metadata/loopback targets (RFC1918, CGNAT, link-local, 169.254.169.254, metadata.google.internal, IPv6 loopback/ULA) with HTTP 400 before fetching.

Fixes #6814
Fixes #6813

Test plan

  • ./node_modules/.bin/jest --ci test/proxy.test.ts (11 passed)
  • Confirm plugin proxies to public hosts still work
  • Confirm x-base-url with ?q=api.openai.com no longer receives the server key
  • Confirm x-base-url: http://169.254.169.254 returns 400

Inject OPENAI_API_KEY only when the parsed hostname is api.openai.com,
and reject private/metadata/loopback targets for the open proxy fallback.

Fixes ChatGPTNextWeb#6814
Fixes ChatGPTNextWeb#6813

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant