fix: do not put the Vertex AI API key in the request URL#575
Draft
pinetops wants to merge 1 commit into
Draft
Conversation
`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).
Owner
|
@pinetops is this ready for review? I usually don't look at drafts. |
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
ChatVertexAI.build_url/1appends 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 theAuthorizationheader still carries the key.