Skip to content

fix(rag): resolve vector_store_registry credentials in /v1/rag/query - #35607

Closed
dcsgod wants to merge 2 commits into
BerriAI:litellm_internal_stagingfrom
dcsgod:bugfix/rag-query-vector-store-registry-resolution
Closed

dcsgod wants to merge 2 commits into
BerriAI:litellm_internal_stagingfrom
dcsgod:bugfix/rag-query-vector-store-registry-resolution

Conversation

@dcsgod

@dcsgod dcsgod commented Aug 2, 2026

Copy link
Copy Markdown

TLDR

Problem this solves:

  • ...

How it solves it:

  • ...

Relevant issues

Linear ticket

Pre-Submission checklist

Please complete all items before asking a LiteLLM maintainer to review your PR

  • I have added meaningful tests
  • My PR passes all CI/CD checks (e.g., lint, format, unit tests)
  • My PR's scope is as isolated as possible; it only solves 1 specific problem
  • I have received a Greptile Confidence Score of at least 4/5 before requesting a maintainer review (Greptile reviews automatically once the PR is opened; only comment @greptileai to re-request a review after pushing changes)

Delays in PR merge?

If you're seeing a delay in your PR being merged, ping the LiteLLM Team on Slack (#pr-review).

Screenshots / Proof of Fix

Type

🆕 New Feature
🐛 Bug Fix
🧹 Refactoring
📖 Documentation
🚄 Infrastructure
✅ Test

Changes

QA runbook

Final Attestation

  • The tests check the right things, including the edge cases, and regressions in the respective real-world customer use-cases are not possible after this PR

@greptile-apps

greptile-apps Bot commented Aug 2, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR resolves managed vector-store registry settings for RAG queries and forwards provider-specific retrieval parameters into vector-store searches.

  • Resolves managed vector-store configuration before invoking litellm.aquery.
  • Passes provider credentials and connection options to asearch.
  • Adds endpoint and core-pipeline regression tests.

Confidence Score: 4/5

This PR should not merge until client-supplied retrieval settings are safety-validated before being forwarded to vector-store providers.

The registry credential fix works for its tested case, but the same broad forwarding path permits authenticated callers to influence provider connection and authentication settings.

Files Needing Attention: litellm/rag/main.py and litellm/proxy/rag_endpoints/endpoints.py

Security Review

The new retrieval-parameter forwarding needs additional safety validation before client-supplied connection settings can reach vector-store providers.

Important Files Changed

Filename Overview
litellm/proxy/rag_endpoints/endpoints.py Resolves managed vector-store registry configuration before authorization scanning and the RAG query call.
litellm/rag/main.py Forwards provider-specific retrieval fields into vector-store search, but currently also forwards unsafe client-controlled connection settings.
tests/test_litellm/proxy/rag_endpoints/test_rag_endpoints.py Adds endpoint coverage proving managed registry credentials reach vector-store search, alongside formatting-only changes.
tests/test_litellm/rag/test_main.py Adds core-pipeline coverage for forwarding provider credentials to vector-store search.

Reviews (1): Last reviewed commit: "fix(rag): resolve vector_store_registry ..." | Re-trigger Greptile

Comment thread litellm/rag/main.py Outdated
Comment on lines +230 to +233
extra_search_params = {k: v for k, v in retrieval_config.items() if k not in _reserved_retrieval_keys}
search_params = {**extra_search_params, **kwargs}
for reserved in ("vector_store_id", "query", "max_num_results", "custom_llm_provider"):
search_params.pop(reserved, None)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 security Unsafe retrieval settings reach providers

When an authenticated caller includes provider connection or credential fields in retrieval_config, this code forwards them to litellm.vector_stores.asearch without the proxy's existing request-safety validation, allowing the caller to alter the vector-store search's outbound connection or authentication settings. How this was verified: The query path preserves unmatched caller fields during registry merging and passes every non-reserved retrieval field to providers that consume those connection settings.

Rule Used: What: For security fix PRs, NEVER mention what sec... (source)

Comment thread litellm/rag/main.py Outdated

# 2. Search vector store
_reserved_retrieval_keys = {"vector_store_id", "top_k", "custom_llm_provider"}
extra_search_params = {k: v for k, v in retrieval_config.items() if k not in _reserved_retrieval_keys}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Medium: Client-controlled endpoint receives proxy credentials

An authenticated caller can supply fields such as api_base through retrieval_config. For example, selecting vertex_ai/search_api with an attacker-controlled api_base makes the provider obtain the proxy's configured Vertex access token and send it in the Authorization header to that URL. Validate the original client payload before registry resolution and reject client-supplied credential and endpoint fields, while continuing to forward credentials added by the server-side registry.

status_code=400,
detail={"error": "retrieval_config must contain 'vector_store_id'"},
)
retrieval_config = await _update_request_data_with_litellm_managed_vector_store_registry(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Low: Resolved credentials are written to debug logs

This helper adds cleartext fields such as api_key to retrieval_config, which line 674 then logs verbatim. Anyone with access to proxy debug logs can recover the vector-store credentials after a query; log only non-sensitive retrieval fields or redact credential values before logging.

@veria-ai

veria-ai Bot commented Aug 2, 2026

Copy link
Copy Markdown
Contributor

PR overview

This pull request updates the /v1/rag/query flow to resolve vector store credentials from vector_store_registry and add them to the retrieval configuration used by RAG providers.

Two security issues remain open. An authenticated caller can direct a provider request to an attacker-controlled endpoint and receive the proxy’s configured access token, creating a concrete credential-exfiltration path. Resolved vector-store credentials may also be exposed in debug logs to anyone with log access, and no issues have yet been addressed.

Open issues (2)

Fixed/addressed: 0 · PR risk: 7/10

@codecov

codecov Bot commented Aug 2, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@dcsgod
dcsgod force-pushed the bugfix/rag-query-vector-store-registry-resolution branch from 620fac2 to 5b02f73 Compare August 2, 2026 18:28
@codspeed

codspeed Bot commented Aug 2, 2026

Copy link
Copy Markdown
Contributor

Merging this PR will not alter performance

✅ 31 untouched benchmarks


Comparing dcsgod:bugfix/rag-query-vector-store-registry-resolution (07b6978) with litellm_internal_staging (491eda3)

Open in CodSpeed

@dcsgod

dcsgod commented Aug 16, 2026

Copy link
Copy Markdown
Author

Fixed?

@yuneng-berri
yuneng-berri deleted the branch BerriAI:litellm_internal_staging September 13, 2026 04:38
@yuneng-berri yuneng-berri reopened this Sep 13, 2026
@mateo-berri

Copy link
Copy Markdown
Contributor

The same fix landed through #34788 and #39452 and shipped in v1.101.0, so I'm closing this as superseded. Thank you for the contribution

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.

3 participants