Skip to content

[INS-351] Added Duffel Test Token Detector#4795

Open
MuneebUllahKhan222 wants to merge 3 commits intotrufflesecurity:mainfrom
MuneebUllahKhan222:duffeltest-detector
Open

[INS-351] Added Duffel Test Token Detector#4795
MuneebUllahKhan222 wants to merge 3 commits intotrufflesecurity:mainfrom
MuneebUllahKhan222:duffeltest-detector

Conversation

@MuneebUllahKhan222
Copy link
Contributor

@MuneebUllahKhan222 MuneebUllahKhan222 commented Mar 6, 2026

Description

This PR adds the Duffel Test API Token Detector for TruffleHog.
It scans for Duffel sandbox API tokens (prefix duffel_test_) and optionally verifies them via the Duffel API.

Regex: \b(duffel_test_[A-Za-z0-9-_]{43})\b

Verification

For verification, we use the Duffel Users API: /identity/customer/users?limit=1.
We send a GET request with the token in the Authorization header.

A response code of:

  • 200 OK → token is valid
  • 401 Unauthorized → token is invalid
  • 403 Forbidden → token exists but is revoked or has insufficient permissions

This endpoint is part of the official Duffel API and can be used safely for verification.
It is read-only, does not create or modify resources, and simply confirms whether the provided token is valid.

Corpora Test

The detector does not appear in the list.
image

Checklist:

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

Note

Medium Risk
Adds a new detector with optional live verification via an external Duffel API call and extends the shared DetectorType protobuf enum, which could affect consumers relying on serialized enum values.

Overview
Adds a new duffeltesttoken detector that matches duffel_test_ tokens, deduplicates findings, redacts output, and (when enabled) verifies validity by calling Duffel’s /identity/customer/users?limit=1 endpoint and interpreting 200/401/403 responses.

Extends the protobuf DetectorType enum with DuffelTestToken (value 1043) and includes new unit/integration tests and a benchmark covering matching and verification error handling.

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

@MuneebUllahKhan222 MuneebUllahKhan222 requested a review from a team March 6, 2026 11:36
@MuneebUllahKhan222 MuneebUllahKhan222 requested review from a team as code owners March 6, 2026 11:36
@MuneebUllahKhan222 MuneebUllahKhan222 changed the title Added Duffel Test Token Detector [INS-351] Added Duffel Test Token Detector Mar 6, 2026
Copy link

@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.

Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

// Format: duffel_test_ + 43 alphanumeric / dash / underscore characters
duffelTestTokenPat = regexp.MustCompile(
`\b(duffel_test_[A-Za-z0-9_-]{43})\b`,
)
Copy link

Choose a reason for hiding this comment

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

Regex word boundary incompatible with hyphen in character class

Low Severity

The regex \b(duffel_test_[A-Za-z0-9_-]{43})\b includes - (hyphen) in the character class, but \b only treats [A-Za-z0-9_] as word characters. If a valid token's 43rd character is a hyphen and the token appears before whitespace, end-of-string, or other non-word characters, the trailing \b won't match (non-word to non-word is not a word boundary), causing the token to go undetected.

Fix in Cursor Fix in Web

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is not an issue as the last character of the token will not be a -

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.

1 participant