Add Mailgun Webhook Token detector#5024
Open
asivaprasad09 wants to merge 1 commit into
Open
Conversation
This commit adds a detector for Mailgun webhook signing tokens: - Detects 32-character hexadecimal tokens with "mailgun" context requirement - Uses context-aware regex to reduce false positives from generic webhook examples - Implements CustomFalsePositiveChecker interface for additional validation - Includes comprehensive test coverage for pattern matching and edge cases The detector adds MailgunWebhookToken (ID 1053) to the detector type enum and follows TruffleHog's best practices for secret detection. Key features: - Case-insensitive hex pattern matching - Requires "mailgun" keyword in nearby context - Deduplication of repeated tokens - Proper SecretParts population - Rotation guide in ExtraData Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Reviewed by Cursor Bugbot for commit c3e3f96. Configure here.
|
|
||
| func (s Scanner) Keywords() []string { | ||
| return []string{"mailgun", "webhook", "signing"} | ||
| } |
Contributor
There was a problem hiding this comment.
Overly broad keywords cause unnecessary detector invocations
Medium Severity
Keywords() returns ["mailgun", "webhook", "signing"] but the regex (via PrefixRegex) requires "mailgun" to be present in the data for any match. The keywords "webhook" and "signing" are extremely common words that will trigger this detector on many irrelevant chunks where no "mailgun" context exists, causing unnecessary regex processing that can never produce results. Only "mailgun" is needed as a keyword.
Additional Locations (1)
Reviewed by Cursor Bugbot for commit c3e3f96. Configure here.
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.


Summary
This PR adds a detector for Mailgun webhook signing tokens used to verify webhook payload signatures.
Key features:
CustomFalsePositiveCheckerinterface for additional validationChanges
MailgunWebhookToken(ID 1053) toproto/detector_type.protopkg/detectors/mailgunwebhooktoken/pkg/engine/defaults/defaults.goPattern Details
The detector uses a context-aware regex pattern:
This requires "mailgun" to appear before the token to avoid false positives from generic 32-character hex strings commonly found in examples and test fixtures.
Testing
All tests pass successfully:
Test coverage includes:
Design Rationale
Why context-aware matching?
Mailgun webhook tokens are 32-character hex strings, a format shared by many other types of secrets (MD5 hashes, other webhook tokens, UUIDs without hyphens). Requiring "mailgun" in nearby context significantly reduces false positives while maintaining high recall for actual Mailgun tokens.
Why no verification?
Webhook signing tokens are used to verify HMAC signatures of incoming webhook payloads. They cannot be verified independently via an API call - they only prove valid when used to verify an actual webhook signature with the corresponding message body and timestamp. Therefore, this detector does not implement verification.
SecretParts Population
The detector properly populates
SecretPartswith:And includes a rotation guide in
ExtraData:🤖 Generated with Claude Code
Note
Low Risk
Additive detector-only change with no auth or engine behavior changes beyond one more default scanner; main risk is extra findings or false positives on generic 32-hex strings near "mailgun".
Overview
Adds Mailgun webhook signing token detection as a new detector type (
MailgunWebhookToken, ID 1053), separate from the existing Mailgun API key detector.The scanner matches 32-character hex strings only when mailgun appears in nearby context (
PrefixRegex), deduplicates hits, and emits results withSecretParts, a Mailgun rotation guide link, and no API verification (signing keys are not verifiable out of band). It also implementsCustomFalsePositiveCheckervia the shared default false-positive list.Wiring includes registering the scanner in default detectors, extending
detector_type.protoand generated protobuf enums, plus unit tests for pattern matching, keywords, and type registration.Reviewed by Cursor Bugbot for commit c3e3f96. Bugbot is set up for automated code reviews on this repo. Configure here.