Repository navigation
feat(proxy): add AES-256-GCM at-rest credential encryption with versioned format and re-encryption migration #31215
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
michelligabriele
merged 6 commits into
litellm_internal_staging
from
litellm_aes256_credential_encryption
Jun 29, 2026
Merged
Changes from 2 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
28cef79
feat(proxy): add AES-256-GCM at-rest credential encryption with versi…
michelligabriele 7cf768d
test(proxy): add behavior scenarios for credential migration endpoints
michelligabriele 3698098
fix(proxy): scan covered tables in encryption check, fix CI lint and …
michelligabriele 3bd0211
fix(proxy): migrate callback_settings credentials, clear CI lint/recu…
michelligabriele 743cf74
fix(proxy): correct dry-run/real-run migrated vs residual-legacy coun…
michelligabriele 8af3536
fix(proxy): make callback-vars residual detection gate-independent in…
michelligabriele File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,64 @@ | ||
| """CLI commands for the at-rest credential encryption migration.""" | ||
|
|
||
| import click | ||
| import rich | ||
|
|
||
| from ...http_client import HTTPClient | ||
|
|
||
|
|
||
| @click.group() | ||
| def encryption(): | ||
| """Migrate at-rest credentials to AES-256-GCM and attest residual state.""" | ||
| pass | ||
|
|
||
|
|
||
| @encryption.command(name="migrate") | ||
| @click.option( | ||
| "--check", | ||
| "check_only", | ||
| is_flag=True, | ||
| default=False, | ||
| help="Read-only residual scan (no writes). Reports legacy values remaining.", | ||
| ) | ||
| @click.option( | ||
| "--dry-run", | ||
| is_flag=True, | ||
| default=False, | ||
| help="Run the full migration walkers without writing any changes.", | ||
| ) | ||
| @click.pass_context | ||
| def migrate(ctx: click.Context, check_only: bool, dry_run: bool): | ||
| """Re-encrypt at-rest credentials into the AES-256-GCM (v2:gcm:) format. | ||
|
|
||
| Requires the proxy to be started with | ||
| ``general_settings.encryption_algorithm: aes-256-gcm``. Idempotent and | ||
| resumable — safe to re-run after an interruption. | ||
|
|
||
| Examples: | ||
| litellm-proxy encryption migrate --check # attestation scan, no writes | ||
| litellm-proxy encryption migrate # perform the migration | ||
| """ | ||
| client = HTTPClient(ctx.obj["base_url"], ctx.obj["api_key"]) | ||
|
|
||
| if check_only: | ||
| response = client.request( | ||
| "GET", "/credentials/migrate-encryption/check" | ||
| ) | ||
| else: | ||
| response = client.request( | ||
| "POST", | ||
| "/credentials/migrate-encryption", | ||
| json={}, | ||
| params={"dry_run": "true"} if dry_run else None, | ||
| ) | ||
|
|
||
| rich.print_json(data=response) | ||
|
|
||
| report = response.get("report", {}) if isinstance(response, dict) else {} | ||
| residual = report.get("residual_legacy") | ||
| if residual is not None and residual > 0: | ||
| rich.print( | ||
| f"[yellow]Residual legacy values remaining: {residual}[/yellow]" | ||
| ) | ||
| elif residual == 0: | ||
| rich.print("[green]No legacy values remaining (residual_legacy == 0).[/green]") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.