Skip to content

bug: Authorization header reflected to upstream APIs #60

@dannykopping

Description

@dannykopping

The Anthropic Go SDK examines the process's environment and automatically configures some options:

https://github.com/anthropics/anthropic-sdk-go/blob/main/client.go#L26-L41

If the host process on which aibridged is running has the ANTHROPIC_AUTH_TOKEN or ANTHROPIC_API_KEY env configured, this will get relayed to Anthropic's API.

In other words, values entirely unrelated to the intercepted request's headers can end up in the intercepted requests being relayed upstream.

// NewClient generates a new client with the default option read from the
// environment (ANTHROPIC_API_KEY, ANTHROPIC_AUTH_TOKEN, ANTHROPIC_BASE_URL). The
// option passed in as arguments are applied after these default arguments, and all
// option will be passed down to the services and requests that this client makes.
func NewClient(opts ...option.RequestOption) (r Client) {
	opts = append(DefaultClientOptions(), opts...)

	r = Client{Options: opts}

We'll need to override Options in the created Client to remove these options.


The same applies for the OpenAI lib we use.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions