Skip to content

Fix Secrets Masker for non-string values - #71685

Open
pulaksaha143 wants to merge 1 commit into
apache:mainfrom
pulaksaha143:fix-secrets-masker-non-string-71275
Open

Fix Secrets Masker for non-string values#71685
pulaksaha143 wants to merge 1 commit into
apache:mainfrom
pulaksaha143:fix-secrets-masker-non-string-71275

Conversation

@pulaksaha143

Copy link
Copy Markdown

Fixes #71275

Description

The SecretsMasker previously only redacted str scalar values. This meant that non-string scalars like int, float, bool, and None passed through in cleartext via the REST API even when their keys matched sensitive keywords (e.g. test-password).

This PR updates _redact_all to invert the type check: it now masks any value that is not explicitly traversed as a collection (dict, tuple, set, list), ensuring that numeric API keys and PINs are securely masked.

Note that merge() seamlessly restores the original non-string scalar without issues because it only checks if the incoming payload contains the string "***" before discarding it in favor of the original value.

Testing

  • Added assertions for numeric and boolean redaction to test_redact_all_directly. All airflow_shared/secrets_masker tests pass successfully.

Fixes apache#71275

The SecretsMasker previously only redacted `str` scalar values, allowing
non-string scalars like `int`, `float`, `bool`, and `None` to pass through
in cleartext even when their keys matched sensitive keywords (e.g. `test-password`).

This updates `_redact_all` to invert the type check: it now masks any value that
is not explicitly traversed as a collection (`dict`, `tuple`, `set`, `list`).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Secrets masker: non-string values are not redacted when the key name is sensitive

1 participant