BerriAI/litellm · error · ValueError
Google KMS requires the encrypted secret to be encoded in ba
Error message
Google KMS requires the encrypted secret to be encoded in base64
What it means
Google KMS branch guard: the environment-held encrypted secret failed base64 decoding, so it cannot be converted to the ciphertext bytes the KMS decrypt call requires. Hardening fix for a reported huntr vulnerability.
Source
Thrown at litellm/secret_managers/secret_manager_handler.py:67
if (
key_manager == KeyManagementSystem.AZURE_KEY_VAULT.value
or type(client).__module__ + "." + type(client).__name__ == "azure.keyvault.secrets._client.SecretClient"
): # support Azure Secret Client - from azure.keyvault.secrets import SecretClient
secret = client.get_secret(secret_name).value
elif (
key_manager == KeyManagementSystem.GOOGLE_KMS.value or client.__class__.__name__ == "KeyManagementServiceClient"
):
encrypted_secret: Any = os.getenv(secret_name)
if encrypted_secret is None:
raise ValueError("Google KMS requires the encrypted secret to be in the environment!")
b64_flag: Final = _is_base64(encrypted_secret)
if b64_flag is True: # if passed in as encoded b64 string
encrypted_secret = base64.b64decode(encrypted_secret)
ciphertext: Final = encrypted_secret
else:
raise ValueError(
"Google KMS requires the encrypted secret to be encoded in base64"
) # fix for this vulnerability https://huntr.com/bounties/ae623c2f-b64b-4245-9ed4-f13a0a5824ce
response = client.decrypt(
request={
"name": litellm._google_kms_resource_name,
"ciphertext": ciphertext,
}
)
secret = response.plaintext.decode("utf-8") # assumes the original value was encoded with utf-8
elif key_manager == KeyManagementSystem.AWS_KMS.value:
"""
Only check the tokens which start with 'aws_kms/'. This prevents latency impact caused by checking all keys.
"""
encrypted_value: Final = os.getenv(secret_name, None)
if encrypted_value is None:
raise Exception(f"AWS KMS - Encrypted Value of Key={secret_name} is None")
# Decode the base64 encoded ciphertextView on GitHub (pinned to 77b7c6c40c)
Solutions
- Base64-encode the KMS ciphertext before storing it in the environment variable (use the output of gcloud kms encrypt --ciphertext-file).
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at litellm/secret_managers/secret_manager_handler.py:67 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of BerriAI/litellm@77b7c6c40c (2026-08-18).
Data as JSON: /api/errors/4b6e1f6bd21832f0.
Report an issue: GitHub.