Skip to content

Add support for detecting and validating CastAI API tokens#4926

Open
patrickpichler wants to merge 1 commit intotrufflesecurity:mainfrom
patrickpichler:add-castai-support
Open

Add support for detecting and validating CastAI API tokens#4926
patrickpichler wants to merge 1 commit intotrufflesecurity:mainfrom
patrickpichler:add-castai-support

Conversation

@patrickpichler
Copy link
Copy Markdown

@patrickpichler patrickpichler commented Apr 28, 2026

Fixes #4925

Description:

This PR adds a custom detector for CastAI API keys.

Checklist:

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

Note

Medium Risk
Adds a new network-verifying detector and a new DetectorType enum value, which can affect default scanning behavior and downstream consumers of detector type IDs. Risk is limited to detector plumbing plus an internal refactor using maps.Copy for AWS extra data merging.

Overview
Adds a new castai detector that finds castai_v1_... API tokens, optionally verifies them via X-API-Key calls against the US/EU CastAI endpoints, and reports the verifying endpoint in ExtraData.

Wires the detector into the default detector set and introduces the new DetectorType_CastAI (CastAI = 1048) in protobuf-generated enums. Includes unit, integration, and benchmark coverage for matching and verification error handling.

Also refactors AWS access key verification result merging to use maps.Copy instead of a manual map loop.

Reviewed by Cursor Bugbot for commit e828423. Bugbot is set up for automated code reviews on this repo. Configure here.

@patrickpichler patrickpichler requested a review from a team April 28, 2026 12:52
@patrickpichler patrickpichler requested review from a team as code owners April 28, 2026 12:52
@CLAassistant
Copy link
Copy Markdown

CLAassistant commented Apr 28, 2026

CLA assistant check
All committers have signed the CLA.

Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

Reviewed by Cursor Bugbot for commit e828423. Configure here.

maps.Copy(s1.ExtraData, extraData)
s1.SetVerificationError(verificationErr, match)
break
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Verification breaks on first endpoint error, skipping alternatives

Medium Severity

When the first endpoint returns a transient error (timeout, 5xx), the loop breaks immediately without trying the remaining endpoint. A token valid on the EU endpoint would be reported as unverified with an error if the US endpoint happens to be temporarily unreachable, since the continue only fires for definitive 401 responses (!isVerified && verificationErr == nil).

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit e828423. Configure here.

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 support for CastAI API key detection

2 participants