[INS-406] Braintrust detector#4826
Open
MuneebUllahKhan222 wants to merge 1 commit intotrufflesecurity:mainfrom
Open
[INS-406] Braintrust detector#4826MuneebUllahKhan222 wants to merge 1 commit intotrufflesecurity:mainfrom
MuneebUllahKhan222 wants to merge 1 commit intotrufflesecurity:mainfrom
Conversation
Comment on lines
+27
to
+37
| // Braintrust API keys: | ||
| // Format: sk- + 48 alphanumeric characters (observed) | ||
| braintrustTokenPat = regexp.MustCompile( | ||
| `\b(sk-[A-Za-z0-9]{48})\b`, | ||
| ) | ||
| ) | ||
|
|
||
| // Keywords used for fast pre-filtering | ||
| func (s Scanner) Keywords() []string { | ||
| return []string{"sk-"} | ||
| } |
Contributor
There was a problem hiding this comment.
A couple of things to flag regarding the use of sk- as a detector keyword:
- Keyword length: We generally avoid using prefixes as keywords unless they're at least 4-5 characters long or distinctive enough to avoid false positives. Since
sk-is only three characters, it's better to rely on more specific, contextually relevant keywords instead. - False positive risk: The
sk-prefix is shared across many different secret types, which means using it as a keyword would likely generate a high volume of false positives.
What do you think?
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
This PR adds the Braintrust API Key Detector for TruffleHog.
It scans for Braintrust API keys (prefix
sk-) and optionally verifies them via the official API.Regex:
\b(sk-[A-Za-z0-9]{48})\bVerification
For verification, we use the Braintrust Projects API: https://api.braintrust.dev/v1/project?limit=1. We send a GET request with the token in the Authorization: Bearer header. A response code of 200 OK means the token is valid. 401 Unauthorized means it is an invalid or revoked token, while 403 Forbidden indicates a valid token with insufficient permissions.
This API endpoint is part of the official Braintrust API and can be used safely for verification. It is read-only and does not perform any destructive actions.
Corpora Test
The detector does not appear in the list.

Checklist:
make test-community)?make lintthis requires golangci-lint)?Note
Medium Risk
Adds a new detector that can make outbound HTTP requests to Braintrust for token verification, which may impact scan performance and behavior under network failures. Also extends the detector type protobuf enum, which can affect downstream consumers relying on stable enum values.
Overview
Adds a new Braintrust API key detector that finds tokens matching
sk-+ 48 alphanumerics, deduplicates matches, redacts output, and (optionally) verifies tokens viaGET https://api.braintrust.dev/v1/project?limit=1treating200/403as valid and401as invalid.Registers the detector in the default detector list and introduces
DetectorType_BrainTrustApiKey(1044) inproto/detectors.proto(and regenerateddetectors.pb.go). Includes unit tests for the regex/keyword behavior plus integration tests/benchmarks covering verification success, invalid tokens, and verification error handling.Written by Cursor Bugbot for commit 83c8446. This will update automatically on new commits. Configure here.