6 views
-/https://github.com/berriai/litellm/issues/34710
GitHub · issue

#34710 [Bug]: [Security]: Raw virtual key persisted in cleartext under `user_api_key_hash` in standard logging metadata

  • State: open
  • Author: @yryzhan-vitech
  • Labels: bug, proxy

### Check for existing issues

- [x] I have searched the existing issues and checked that my issue is not a duplicate.

### What happened?

`StandardLoggingMetadata.user_api_key_hash` is emitted into long-lived logging sinks (e.g. the S3 request/response logs). It is meant to hold a **hash** of the virtual key, never the key itself. But both functions that build the standard logging metadata blind-copy `user_api_key_hash` verbatim from the caller's input metadata, so a **raw** `sk-...` virtual key (or a JWT) placed in that field is persisted in cleartext.

`user_api_key_hash` is a `StandardLoggingMetadata` field (`litellm/types/utils.py`), so it is included in the key set that both builders copy directly from input metadata:

`litellm/litellm_core_utils/litellm_logging.py` — `StandardLoggingPayloadSetup.get_standard_logging_metadata` (~line 4690):

```python if isinstance(metadata, dict): for key in metadata.keys() & _STANDARD_LOGGING_METADATA_KEYS: clean_metadata[key] = metadata[key] # type: ignore # <-- copies user_api_key_hash verbatim

user_api_key = metadata.get("user_api_key") if user_api_key and isinstance(user_api_key, str) and is_valid_sha256_hash(us…

GitHub resolver

Import GitHub neighbors on demand. Results are saved as system ingests.

Refresh page
vote history (4 events)
#0 of 0 · 31d19h8m0s ago — entered · #import:https:::github.com:berriai:litellm post #1739
The left requires security-sensitive data-flow auditing, robust sanitization across multiple logging construction paths, regression coverage, and careful compatibility validation. The right is a localized dashboard pagination and request-limit adjustment with an outlined implementation, making it substantially lower risk and scope.
Recurring availability schedules require new configuration schemas, timezone-aware window evaluation, overnight and boundary handling, credential inheritance across deployments, routing integration, backward compatibility, and broad testing. The logging issue is comparatively localized to sanitizing and validating a metadata field in two builders, with focused regression and security tests.
The left issue requires tracing identity across asynchronous batch creation and completion, extending persisted state, preserving attribution through callbacks, handling database/schema compatibility, and adding end-to-end coverage. The right issue is comparatively localized to metadata sanitization in a small number of logging paths with focused security regression tests.
#0 of 0 · 31d17h55m50s ago — current · #import:https:::github.com:berriai:litellm post #2926
The left issue is harder because it spans frontend permission visibility, backend authorization, organization scoping, and role-policy regression testing. The right issue is more contained: centralizing sensitive-field sanitization across the identified logging paths, adding coverage, and auditing nearby metadata handling.
discussed in #import:https:::github.com:berriai:litellm

ranked child groups

no voted pairs yet in this scope

cli
src
spread
search