Skip to content

Add Persona (withpersona.com) API key detector#4851

Open
segiddins wants to merge 1 commit intotrufflesecurity:mainfrom
segiddins:segiddins/add-persona-detector
Open

Add Persona (withpersona.com) API key detector#4851
segiddins wants to merge 1 commit intotrufflesecurity:mainfrom
segiddins:segiddins/add-persona-detector

Conversation

@segiddins
Copy link
Copy Markdown

@segiddins segiddins commented Mar 31, 2026

Description:

Adds a new detector for Persona API keys. Persona is an identity verification platform; leaked API keys can expose sensitive PII, government IDs, and verification results.

Key format: persona_sandbox_<uuid> / persona_production_<uuid>

Verification: GET https://withpersona.com/api/v1/api-keys/permissions with Bearer auth

  • 200 → verified (extracts org ID, environment ID, key name, permissions, expiration)
  • 401/403 → unverified
  • Other → indeterminate

I work at Persona.

Closes #4850

Checklist:

  • Tests passing (make test-community)?
  • Lint passing (make lint this requires golangci-lint)?

Note

Medium Risk
Medium risk because it introduces a new network-backed verification path and extends the shared DetectorType protobuf enum, which can impact compatibility if downstream consumers rely on enum values.

Overview
Adds a new persona detector that matches persona_sandbox_<uuid> / persona_production_<uuid> keys and, when verify is enabled, calls Persona’s api-keys/permissions endpoint to mark findings as verified and enrich ExtraData (org/env IDs, key metadata, permissions, expiration).

Registers the detector in pkg/engine/defaults so it runs by default, and extends proto/detectors.proto + generated detectors.pb.go with a new DetectorType_Persona enum value, with accompanying pattern/verification tests.

Written by Cursor Bugbot for commit 45d3510. This will update automatically on new commits. Configure here.

Add a new detector for Persona identity verification platform API keys.
Keys follow the format persona_{sandbox|production}_<UUID> and are
verified against the Persona API permissions endpoint.

Extracts metadata on verification: key type, organization, environment,
API key ID, name, permissions, and expiration.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@segiddins segiddins requested a review from a team March 31, 2026 04:17
@segiddins segiddins requested review from a team as code owners March 31, 2026 04:17
@CLAassistant
Copy link
Copy Markdown

CLAassistant commented Mar 31, 2026

CLA assistant check
All committers have signed the CLA.

for k, v := range extraData {
s1.ExtraData[k] = v
}
s1.AnalysisInfo = map[string]string{"key": keyMatch}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need for analysis, as there is currently no Analyzer available for this secret type.

func verifyPersonaKey(ctx context.Context, client *http.Client, key string) (bool, map[string]string, error) {
req, err := http.NewRequestWithContext(ctx, http.MethodGet, "https://withpersona.com/api/v1/api-keys/permissions", http.NoBody)
if err != nil {
return false, nil, nil
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason we’re not returning the error here?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the tests. This is great.

One small suggestion: it would be nice to follow the convention of separating unit tests and integration tests (you can check out this example for reference).

Also, for handling keys in tests, the “Testing the Detector” guide is a helpful resource to follow.

Comment on lines +125 to +126
case http.StatusUnauthorized, http.StatusForbidden:
return false, nil, nil
Copy link
Copy Markdown
Contributor

@nabeelalam nabeelalam Mar 31, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to the Persona API error codes documentation a 403 Forbidden response indicates that credentials are valid but lack permission for this call.

I'm not sure how accurate it would be to unverify these credentials in this case.

Comment on lines +61 to +69
s1.Verified = isVerified
s1.SetVerificationError(err, keyMatch)

if isVerified {
for k, v := range extraData {
s1.ExtraData[k] = v
}
s1.AnalysisInfo = map[string]string{"key": keyMatch}
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As pointed out, no need to populate AnalysisInfo here.

This whole block can be simplified to:

s1.Verified = isVerified
s1.ExtraData = extraData
s1.SetVerificationError(err, keyMatch)

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.

Add Persona (withpersona.com) API Key Detector

4 participants