Repository navigation
Flag Magic sk_ secret keys in Gitleaks - #1143
Merged
Merged
Conversation
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
jerry-payward
approved these changes
Dec 2, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
📦 Pull Request
Gitleaks catches Magic secret keys only through its default Stripe rule (
stripe-access-token). That rule matches the oldsk_live_keys by accident and misses the newsk_v2_+ 64 hex keys from magiclabs/dashboard-api#499. The defaultgeneric-api-keyrule catches a key only in aKEY=valuestyle assignment.magic-secret-keyrule:(?i)\b(sk_[a-z0-9_]{16,99})\b, keywordsk_. It matches anysk_key, so both the oldsk_live_keys and the newsk_v2_keys are caught by a Magic rule rather than by the Stripe one. It is case-insensitive because the backends resolve a key by the SHA-256 of its uppercased value, soSK_V2_…and the lowercase form are the same key.sk_live_/sk_test_keys now also match this rule, alongsidestripe-access-token.CI config only, so
skip-release.🚨 Test instructions
Gitleaks runs in CI only. The rules' regexes (this file plus the 8.24.3 default config) ran through Go's
regexp, the RE2 engine Gitleaks uses, against sample strings:sk_v2_-only rule:sk_live_+ 16 hex andsk_live_+ 32 hex, as a quoted string, an env line and bare text, matched onlystripe-access-token.sk_v2_+ 64 hex as a string, an env line, lowercase andSK_V2_, all matchmagic-secret-key. Thesk_live_XXXXXXXXandsk_v2_XXXXXXXXdoc placeholders and a bare"sk_"match nothing.sk_live_supersecret.No sample key is committed.
🤖 Generated with Claude Code