Repository navigation
FEAT: Detect OpenAI, Anthropic, and Hugging Face API keys in CredentialLeakScorer - #3286
Merged
Roman Lutz (romanlutz) merged 6 commits intoOct 20, 2026
Merged
Conversation
Contributor
|
Adding these modern provider key signatures to CredentialLeakScorer fills a noticeable gap. The negative lookahead on the OpenAI prefix cleanly avoids misattributing Anthropic keys without requiring complex ordering between patterns. Adding the named credential group to GARAK_PATTERNS also keeps exclusion filtering functional across all three token families. Ran the full regex scorer test suite and everything is green. |
Roman Lutz (romanlutz)
enabled auto-merge
October 19, 2026 14:04
Roman Lutz (romanlutz)
approved these changes
Oct 19, 2026
Backport the existing startup and preference persistence fix from microsoft#3356 (7a8a341). Wait for runtime readiness and configured defaults before normal startup interactions, and confirm operation preferences are persisted before reloads. Preserve intentional early-startup coverage. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: f496faeb-6d01-47ac-9c54-1e0a9665078b
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.
Description
Closes #3285
Adds detection for major AI platform credentials to
CredentialLeakScorer:(?<![A-Za-z0-9_-])sk-(?!ant-)(?:proj-|admin-|svcacct-)?[A-Za-z0-9_-]{48,200}(?![A-Za-z0-9_-])(supports classicsk-, modern projectsk-proj-, adminsk-admin-, and service accountsk-svcacct-keys; negative lookahead prevents misattribution of Anthropic keys).(?<![A-Za-z0-9_-])sk-ant-[A-Za-z0-9_-]{80,140}(?![A-Za-z0-9_-])(supports standardsk-ant-api03-, adminsk-ant-admin01-, and OAuth tokens).(?<![A-Za-z0-9])hf_[A-Za-z0-9]{34,80}(?![A-Za-z0-9])(supports user access tokens and fine-grained access tokens).Explicit negative lookaround boundaries are used across both
_DEFAULT_PATTERNSandGARAK_PATTERNS(with(?P<credential>...)capturing the whole token including trailing hyphens for exact exclusion support, overlong token rejection, and non-ASCII / CJK surrounding text compatibility).Tests and Documentation
test_credential_detectedandtest_credential_not_detected.test_credential_scorer_detects_openai_keys,test_credential_scorer_detects_anthropic_key,test_credential_scorer_detects_hugging_face_token).GARAK_PATTERNS, overlong token rejection, and non-ASCII/Chinese context detection.test_garak_patterns_are_opt_in(15 default, 59 expanded) andtest_api_key.py.