feat(detectors): add Cloud Storage HMAC key detector by DrFaust92 · Pull Request #5439 · trufflesecurity/trufflehog · GitHub
Skip to content

feat(detectors): add Cloud Storage HMAC key detector - #5439

Open
DrFaust92 wants to merge 1 commit into
trufflesecurity:mainfrom
DrFaust92:feat/gcs-hmac-detector
Open

DrFaust92 wants to merge 1 commit into
trufflesecurity:mainfrom
DrFaust92:feat/gcs-hmac-detector

Conversation

@DrFaust92

@DrFaust92 DrFaust92 commented Oct 17, 2026 •

Copy link
Copy Markdown

Closes #5339.

What

  • Adds a gcshmac detector for Google Cloud Storage HMAC keys: a GOOG-prefixed access ID (61 chars for service accounts, 24 for user accounts, per the HMAC key docs) paired with a nearby 40-char base64 secret, reusing the AWS detector's secret pattern, entropy thresholds and hex false-positive filter.
  • ExtraData carries account_type (service vs user account, from the ID length).
  • Verification is a SigV4-signed ListBuckets against storage.googleapis.com. 200 and 403 AccessDenied verify (the signature was accepted, the key just can't list buckets); SignatureDoesNotMatch/InvalidAccessKeyId are determinate negatives; anything else is indeterminate.

Why

I confirmed against the live API that an unknown access ID comes back as 403 SignatureDoesNotMatch rather than InvalidAccessKeyId. I haven't run the positive path against a real key, so 200/AccessDenied for a valid key follows the XML API's documented behaviour and is covered by httptest only. The enum is 1075 because #5338 already takes 1074.

Checklist:

  • Tests passing (go test ./pkg/detectors/gcshmac/... ./pkg/engine/defaults/...)
  • Lint passing (golangci-lint run ./pkg/detectors/gcshmac/...)

🤖 Generated with Claude Code


Note

Medium Risk
Adds live credential verification against GCS and reuses AWS secret heuristics, which could mis-pair IDs/secrets or trigger outbound auth attempts when verification is enabled.

Overview
Adds a new gcshmac detector for Google Cloud Storage HMAC keys (GOOG… access ID + 40-char secret), wired into default detectors and DetectorType_GCSHMACKey (1076).

Detection pairs GOOG-prefixed IDs (24- or 61-char user/service accounts) with nearby secrets using the AWS detector’s secret regex, entropy checks, URL decoding, and hex false-positive filtering. Results include account_type in ExtraData. Optional verification signs a SigV4 ListBuckets request to storage.googleapis.com; 200 and AccessDenied count as verified, while signature/access-key errors are treated as invalid.

Unit tests cover common config shapes (AWS env vars, boto gs_* keys, S3 URLs), negative cases, and mocked verification responses.

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

@DrFaust92
DrFaust92 requested a review from a team October 17, 2026 02:20
@DrFaust92
DrFaust92 requested a review from a team as a code owner October 17, 2026 02:20
@DrFaust92
DrFaust92 force-pushed the feat/gcs-hmac-detector branch from d5d56f5 to ac74561 Compare October 17, 2026 02:23
Anchors on the GOOG-prefixed access ID (61 chars for service accounts,
24 for user accounts) paired with a nearby 40-char base64 secret, since
these keys are usually stored under AWS names and the secret alone is
indistinguishable from an AWS one. Verifies with a SigV4-signed
ListBuckets against the XML API; AccessDenied still means the signature
was accepted, while an unknown ID or wrong secret both come back as
SignatureDoesNotMatch.

Closes trufflesecurity#5339.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@DrFaust92

Copy link
Copy Markdown
Author

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 a Cloud Storage HMAC key detector

1 participant