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 was referenced Aug 17, 2026
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 with_configure_destination_mode()and cleared after the first call; the deployer never needs to inject it into the K8s SecretAICORE_CLIENT_SECRETis removed fromos.environafter the first successful completion call.Code that reads
os.environ["AICORE_CLIENT_SECRET"]after callingcompletion()oracompletion()will receive aKeyError(or empty string via.get()).Affected pattern:
Known affected agents — migration required before this PR merges:
PMDRA/skills_agent.pyAICORE_CLIENT_SECRETfrom env post-completion()billing-anomaly/_credentials.pyAICORE_CLIENT_SECRETfrom env post-completion()Issues have been opened in the respective repos with the migration path below. This PR stays draft until all three confirm migration or provide a timeline.
Migration path:
Remove any code that reads
AICORE_CLIENT_SECRETdirectly fromos.environafterset_aicore_config()/completion(). The secret is an implementation detail of the LiteLLM integration — application code should not depend on it.If the secret is needed for a purpose outside LiteLLM (e.g. a separate HTTP call), read it directly from the mounted secret volume at
/etc/secrets/appfnd/aicore/<instance>/clientsecretbefore callingset_aicore_config().Related Issues
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
Additional Notes
This is the second in a series of 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.