Skip to content

fix(plugins): redact credential patterns in free-text values, not just exact keys - #6499

Open
prasanna8585 wants to merge 1 commit into
google:mainfrom
prasanna8585:fix/bq-analytics-plugin-freetext-credential-redaction
Open

fix(plugins): redact credential patterns in free-text values, not just exact keys#6499
prasanna8585 wants to merge 1 commit into
google:mainfrom
prasanna8585:fix/bq-analytics-plugin-freetext-credential-redaction

Conversation

@prasanna8585

Copy link
Copy Markdown

_recursive_smart_truncate -> _sanitize_json_blob / _sanitize_free_text is the sanitization path used for tool args/results, session-state deltas, usage/cache metadata, A2A payloads, and tool schemas. That path only pattern-inspects JSON-container-shaped strings; plain prose values passed through unredacted with only exact dict-key matches against _SENSITIVE_KEYS being caught. This wires the existing _redact_sensitive_patterns() pass (already used for signed-URI segments, Part-content text, and error/traceback text) into the two prose fallback branches so credential-shaped text is caught regardless of which key it's nested under.

Verified against the existing test suite (437 passed, 0 regressions) with a new regression test added for the fixed gap.

…t exact keys

_recursive_smart_truncate -> _sanitize_json_blob / _sanitize_free_text
is the sanitization path used for tool args/results, session-state
deltas, usage/cache metadata, A2A payloads, and tool schemas (every
event type BigQueryAgentAnalyticsPlugin logs except proper LLM Part
content, which already goes through _sanitize_strings ->
_sanitize_sensitive_text).

That path only pattern-inspects strings that are JSON-container-shaped
(start with '{' or '['); plain prose values were returned completely
unchanged, with only exact dict-key matches against _SENSITIVE_KEYS
redacted. A credential embedded in ordinary text under an unrecognized
key -- e.g. a tool's own status/error message containing
'Authorization: Bearer sk-...' or 'api_key: sk-...' -- reached BigQuery
in plaintext.

This wires the existing _redact_sensitive_patterns() pass (already used
for signed-URI segments, Part-content text, and error/traceback text)
into the two prose fallback branches of _sanitize_json_blob and
_sanitize_free_text, so credential-shaped text is caught regardless of
which key it's nested under or whether it's JSON-shaped at all.

Verified against the existing test suite (437 passed, 0 regressions)
and added a regression test covering the reported gap.
@adk-bot adk-bot added the tracing [Component] This issue is related to OpenTelemetry tracing label Jul 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

tracing [Component] This issue is related to OpenTelemetry tracing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants