Skip to content

Conversation

@prathmesh-stripe
Copy link
Contributor

Potential fix for https://github.com/stripe/stripe-python/security/code-scanning/7

To fix this, we must ensure that any data passed to logging functions cannot inadvertently include sensitive fields like "api_key" or "Authorization". The best way to accomplish this is by filtering out or redacting such sensitive values from dictionaries before formatting and logging them. Specifically, just before logging request details, defensive code should be inserted to remove (pop) or replace values of sensitive keys (such as "api_key", "Authorization", and even "headers" fields that may contain such keys) with a placeholder (e.g., "REDACTED"). This should be done at the start of the logging functions, or in a helper that is called on all logging parameters.

To implement:

  • Add a helper function in stripe/_util.py (in the provided code region) that takes a dictionary and returns a copy with sensitive keys redacted ("api_key", "Authorization", "password", etc.).
  • Use this helper in log_info and log_debug functions before logging params.

Suggested fixes powered by Copilot Autofix. Review carefully before merging.

…nsitive information

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
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.

1 participant