Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Redact anything resembling Stripe keys when logging #894

Open
richardm-stripe opened this issue May 15, 2020 · 3 comments
Open

Redact anything resembling Stripe keys when logging #894

richardm-stripe opened this issue May 15, 2020 · 3 comments
Labels

Comments

@richardm-stripe
Copy link
Contributor

No description provided.

@jonchurch
Copy link
Contributor

jonchurch commented May 29, 2020

For anyone looking for it, I believe this RegEx matches anything stripe-key-like:

/(pk|sk)_(test|live)_[A-Za-z0-9]+/

Preview on regexpal.com

The stricter version of this would be to check that it's the right length as well:
EDIT: This approach is flawed as noted below, stripe key length is not guaranteed in the future.

/(pk|sk)_(test|live)_[A-Za-z0-9]{24}}/

@remi-stripe
Copy link
Contributor

@jonchurch Just for completeness, we have API keys of different lengths and we will keep increasing the length over time. Also many API keys have different formats, legacy ones don't have test or live or not even pk_ or sk_. Restricted API keys start with rk_ while ephemeral keys start with ek_. I would discourage anyone from using a regex for anything that isn't just logging.

@jonchurch
Copy link
Contributor

jonchurch commented Jun 1, 2020

That's good information, thank you. For anyone who finds this later, it's likely best for you to scrub specific fields from logging, and only use a regex as a backup or to verify output in tests w/ testing keys.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants