Skip to content

fix(plugins): keep secret_key and passwd args out of tracing spans - #8237

Closed
Johnbjoseph-cybersec wants to merge 1 commit into
google:mainfrom
Johnbjoseph-cybersec:fix/autotracing-secret-arg-names
Closed

Johnbjoseph-cybersec wants to merge 1 commit into
google:mainfrom
Johnbjoseph-cybersec:fix/autotracing-secret-arg-names

Conversation

@Johnbjoseph-cybersec

Copy link
Copy Markdown
Contributor

Link to Issue or Description of Change

2. No issue exists; the bug is described here following the bug report template.

Problem:

Describe the Bug: AutoTracingPlugin drops secret-named arguments via utils/_credential_names.py; DebugLoggingPlugin keeps its own, broader list. secret_key, stripe_secret_key, aws_secret_access_key, passwd and db_passwd are redacted in the debug log, but written verbatim as an adk.fn.arg.<name> span attribute. Likewise x_amz_signature, x_goog_signature.

Steps to Reproduce: AutoTracingPlugin + in-memory exporter; call fn(user, secret_key, aws_secret_access_key, passwd, db_password, api_key) with a sentinel.

Expected Behavior: arguments DebugLoggingPlugin treats as secrets stay off the span, like api_key today.

Observed Behavior (at c74df83):

secret_key               AutoTracing span attr="'SENTINEL-SECRET-VALUE-1234'"   DebugLogging redacts=True
aws_secret_access_key    AutoTracing span attr="'SENTINEL-SECRET-VALUE-1234'"   DebugLogging redacts=True
passwd                   AutoTracing span attr="'SENTINEL-SECRET-VALUE-1234'"   DebugLogging redacts=True
db_password              AutoTracing span attr=None                             DebugLogging redacts=True
api_key                  AutoTracing span attr=None                             DebugLogging redacts=True
SENTINEL in span attributes: True      (exit 1)

Environment Details: ADK at c74df83 (2.14.1), macOS 27.0.1, Python 3.11.17.

Model Information: N/A (no model call involved).

Solution:

Add those names to CREDENTIAL_ARG_NAMES, and _passwd, _secret_key and _secret_access_key to CREDENTIAL_ARG_SUFFIXES. Suffix matching is kept, so secretary and prompt_token_count are still traced. sig, signature and google_access_id are deliberate, named exclusions in the drift test (ordinary parameter names); your call.

Testing Plan

Unit Tests:

  • I have added or updated unit tests for my change.

  • All unit tests pass locally.

  • test_credential_named_args_are_not_recorded: new names dropped; secretary, passage, key_count still traced.

  • test_serialization.py: drift guard over DebugLoggingPlugin keys, substrings and suffixes; spellings; ordinary names stay False.

New tests: 15 failed on main, 77 passed with the fix. Removing any single added entry fails at least one test. pytest tests/unittests -n 8: 25739 passed on main, 25786 passed with the fix, 0 failed. tox ran py311 to py314 green, with testenv.runner=uv-venv-runner, because uv.lock is gitignored and the shipped --locked runner cannot sync without it.

Manual End-to-End (E2E) Tests:

The repro now prints attr=None for all five (exit 0).

Checklist

  • I have read the CONTRIBUTING.md document.
  • I have performed a self-review of my own code.
  • I have commented my code, particularly in hard-to-understand areas.
  • I have added tests that prove my fix is effective or that my feature works.
  • New and existing unit tests pass locally with my changes.
  • I have manually tested my changes end-to-end.
  • Any dependent changes have been merged and published in downstream modules. N/A

Additional context

Same class as #7311 / #7312. #8054 also edits test_serialization.py and adds passwd to a separate list in utils/_redaction.py. #7845 proposes a pluggable TelemetrySanitizer.

John B Joseph, Co-founder & CPTO, Purplecop Security

AutoTracingPlugin drops credential-named arguments using the shared rule in
utils/_credential_names.py, while DebugLoggingPlugin keeps its own, broader
key list. A parameter named secret_key, stripe_secret_key,
aws_secret_access_key, passwd or db_passwd was redacted in the debug log but
recorded verbatim as an adk.fn.arg.<name> span attribute.

Add those spellings, and the x_amz_signature and x_goog_signature keys, to
the shared names and suffixes. Suffix matching is kept, so names such as
secretary and prompt_token_count are still traced. New tests assert every
DebugLoggingPlugin key, substring and suffix is matched by the shared rule,
apart from google_access_id, sig and signature, which are left alone on
purpose.
@jawoszek jawoszek assigned RKest and unassigned jawoszek Nov 23, 2026
copybara-service Bot pushed a commit that referenced this pull request Nov 24, 2026
Merge #8237

`AutoTracingPlugin` drops credential-named arguments using `utils/_credential_names.py`, while `DebugLoggingPlugin` keeps a broader key list. Parameters named `secret_key`, `stripe_secret_key`, `aws_secret_access_key`, `passwd`, or `db_passwd` were redacted in the debug log but recorded verbatim as `adk.fn.arg.<name>` span attributes.

Add `passwd`, `secret_key`, `secret_access_key`, `x_amz_signature`, and `x_goog_signature` to `CREDENTIAL_ARG_NAMES` and `_passwd`, `_secret_key`, and `_secret_access_key` to `CREDENTIAL_ARG_SUFFIXES`, keeping suffix matching so names like `secretary` and `prompt_token_count` stay traced. Add drift tests checking `DebugLoggingPlugin` keys, substrings, and suffixes against `is_credential_arg_name` (excluding ordinary parameter names `google_access_id`, `sig`, and `signature`).

Co-authored-by: Max Ind <maxind@google.com>
PiperOrigin-RevId: 1028877481
@adk-bot

adk-bot commented Nov 24, 2026

Copy link
Copy Markdown
Collaborator

Thank you @Johnbjoseph-cybersec for your contribution! 🎉

Your changes have been successfully imported and merged via Copybara in commit e3dbdc1.

Closing this PR as the changes are now in the main branch.

@adk-bot adk-bot added the merged [Status] This PR is merged label Nov 24, 2026
@adk-bot adk-bot closed this Nov 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merged [Status] This PR is merged

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants