Repository navigation
feat(session): support credential masking before persistence - #5924
Closed
J-StrawHat wants to merge 2 commits into
Closed
J-StrawHat wants to merge 2 commits into
J-StrawHat wants to merge 2 commits into
Conversation
Collaborator
Author
|
New implementation: PR #6278 |
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
Session messages may contain important credentials (e.g., ak/sk, API key, password) in user text, tool arguments, tool results, and context abstracts. Persisting those values also makes them available to later memory extraction.
This PR add opt-in, offline credential masking at the shared Session append boundary, before message construction, tool-output externalization, or persistence.
Enable it with
memory.session_secret_masking_enabled: trueinov.conf(The default isfalse, preserving existing behavior). The scanner masks private copies of message content without changing caller-owned tool arguments. For example,API_KEY=abcdefghijklmnopqrstuvwxyzis stored asAPI_KEY=ab****yz, while ordinary fields such asregion,max_tokens,token_count, andcache_keyremain unchanged. No new HTTP API, third-party dependency, model call, or online credential verification is introduced.Human Involvement
Type of Change
Changes Made
EVAL_ARK_API_KEY,MY_COMPANY_API_KEY, andMY-API-KEY.[REDACTED]. Sensitive non-string field values, including containers, are replaced as a whole. Preserve Bearer/Basic authentication schemes and already-masked values.Supported credential types
sk-,sk-proj-,sk-svcacct-,sk-ant-and itsapiN-variants;ak-and Arkark-; VolcengineAKLT/AKTP; AWSAKIA/ASIAAccess Key IDs.ghp_,gho_,ghu_,ghs_,ghr_, andgithub_pat_.ak,sk,api_key,x_api_key,access_key,access_key_id,secret_key,secret_access_key, andaccess_key_secret, including supported aliases and namespace suffixes. Unprefixed secret values are detected through field context.token,access_token,refresh_token,session_token,auth_token,security_token,bot_token;password,passwd,pwd;secret,client_secret,app_secret,private_key,signing_key,signing_secret,webhook_secret,credential, andcredentials.Authorization, andProxy-Authorization.=separators and quoted/escaped values, plus curl--oauth2-bearer,--user/-u, and--proxy-user/-U. Combineduser:passwordvalues are fully replaced.Testing
Validation was performed locally on macOS:
Checklist
Screenshots (if applicable)
When chatting with the agent:

Memory stored in OpenViking: (important credentials have been masked)

Additional Notes
Detection is best-effort and based on known formats and sensitive field context. This does not identify every arbitrary random string, decode encoded credentials, inspect images or referenced resources, or rewrite historical content. No original-value mapping is retained. The feature is independent of whether memory extraction is enabled.