Skip to content

Upstream error responses forwarded verbatim may leak provider credentials #67

@iBreaker

Description

@iBreaker

Problem

When an upstream provider returns an HTTP 4xx/5xx error, the proxy forwards the raw JSON response body directly to the proxy user without any sanitization.

Affected locations in crates/nyro-core/src/proxy/handler.rs:

  • Line 779-781: Json(resp) returns raw upstream error body
  • Lines 764, 907, 1081: format!("upstream error: {e}") exposes internal error details
  • Lines 194: same pattern in embeddings proxy

Why this is a problem

Some upstream providers echo credential fragments in error messages. For example, OpenAI returns:

Incorrect API key provided: sk-proj-abc...xyz. You can find your API key at https://platform.openai.com/account/api-keys.

This means a proxy user can learn the operator's API key prefix/suffix when the upstream returns an auth error.

Exploit scenario

  1. Proxy is configured with the operator's OpenAI API key
  2. The key expires or is revoked
  3. A proxy user sends a request; upstream returns 401 with partial key in the error message
  4. The gateway forwards this error verbatim to the proxy user

Recommendation

Sanitize upstream error responses before returning to proxy users. Return a generic gateway error and log the raw upstream error server-side only.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions