feat(aicore): clear AICORE_CLIENT_SECRET after token acquisition (AFSDK-4291) - #257
Draft
tiagoek wants to merge 1 commit into
Draft
feat(aicore): clear AICORE_CLIENT_SECRET after token acquisition (AFSDK-4291)#257tiagoek wants to merge 1 commit into
tiagoek wants to merge 1 commit into
Conversation
… acquisition After the first successful litellm.completion() call, AICORE_CLIENT_SECRET is removed from os.environ. LiteLLM has captured the secret inside its token creator closure at that point and no longer reads from the environment. Removing it minimises the exposure window to child processes and container introspection APIs (AFSDK-4291 / HASI2026203 SEC-309). The flag is reset when credentials are reloaded (credential rotation flow) so the secret is cleared again after the retry succeeds. No-op in transparent TLS mode where the secret was never written. Relates-to: AFSDK-4291
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Description
Stacked on #256 — merge that PR first, then retarget this one to
main.After the first successful
litellm.completion()/litellm.acompletion()call,AICORE_CLIENT_SECRETis removed fromos.environ. At that point LiteLLM has already captured the secret inside its token creator closure and no longer reads it from the environment. Removing it minimises the window of exposure to child processes and container introspection APIs.Behaviour details
AuthenticationErrorreload_aicore_credentials()(from feat(aicore): transparent TLS mode and reactive credential reload #256) resets the internal flag before re-callingset_aicore_config(), so the secret is written back temporarily and cleared again after the retry succeedsset_aicore_config()never writesAICORE_CLIENT_SECRETto begin withreload_aicore_credentials()exported from the moduleCode that reads
os.environ["AICORE_CLIENT_SECRET"]after callingcompletion()oracompletion()will receive aKeyError(or empty string via.get()). This pattern is an anti-pattern — the secret should only be consumed by the SDK, not by application code — but it exists in some downstream agents. Those agents will need to be updated to fetch credentials directly from the mounted secret volume rather than relying on the SDK's env var.A scan of known downstream consumers identified two agents with confirmed breakage and several with patterns to review. This PR is kept as a draft to allow that migration to be coordinated before merge.
Related Issue
Type of Change
How to Test
python -m pytest tests/aicore/unit/ -v # Expected: 73 passedManual verification:
set_aicore_config()followed by a successfulcompletion()callos.environ.get("AICORE_CLIENT_SECRET")isNonecompletion()call — verify it succeeds (LiteLLM uses its cached token)AuthenticationErrorcompletion()recovers: reloads credentials, clears secret again after retryChecklist
Breaking Changes
AICORE_CLIENT_SECRETis removed fromos.environafter the first successful completion call.Affected pattern:
Migration path: read credentials directly from the mounted volume (
/etc/secrets/appfnd/aicore/<instance>/clientsecret) rather than fromos.environ. Application code should not depend on the SDK's credential env vars — they are an implementation detail of the LiteLLM integration.Additional Notes
This is the second in a series of two stacked PRs addressing credential exposure in the
aicoremodule:AuthenticationErrorCLIENT_SECRETfrom env after token acquisitionWhen #256 is merged to
main, this PR should be retargeted fromfeat/aicore-transparent-tlstomainbefore merging.