Skip to content

fix: do not put the Vertex AI API key in the request URL#575

Draft
pinetops wants to merge 1 commit into
brainlid:mainfrom
u2i:fix/vertex-api-key-not-in-url
Draft

fix: do not put the Vertex AI API key in the request URL#575
pinetops wants to merge 1 commit into
brainlid:mainfrom
u2i:fix/vertex-api-key-not-in-url

Conversation

@pinetops

@pinetops pinetops commented Jul 2, 2026

Copy link
Copy Markdown

Problem

ChatVertexAI.build_url/1 appends the API key as a query parameter:

"#{endpoint}/models/#{model}:#{get_action(vertex_ai)}?key=#{get_api_key(vertex_ai)}"

The same key is also already sent as a bearer token (auth: {:bearer, get_api_key(vertex_ai)} in the Req options), so the query-string copy is redundant. It is also a credential-leak vector: full request URLs routinely appear in server/proxy access logs, error trackers, and browser history — exposing the API key.

Fix

Drop ?key=... from the URL. Authentication is unchanged — the bearer token in the Authorization header still carries the key.

`build_url/1` appended the API key as a query parameter
(`?key=#{get_api_key(...)}`). The key is *also* already sent as a bearer
token (`auth: {:bearer, get_api_key(vertex_ai)}` in the Req options), so
the query-string copy is redundant — and it is a credential-leak vector:
full request URLs routinely land in server/proxy access logs, error
trackers, and browser history, exposing the key.

Drop the `?key=...` from the URL; authentication is unchanged (the
bearer token in the Authorization header still carries it).
@brainlid

brainlid commented Jul 4, 2026

Copy link
Copy Markdown
Owner

@pinetops is this ready for review? I usually don't look at drafts.

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.

2 participants