Skip to content

fix: stop treating HubSpot WAF 403 block pages as verified tokens - #5170

Open
pasmud wants to merge 1 commit into
trufflesecurity:mainfrom
pasmud:fix/5164-hubspot-403-verification
Open

fix: stop treating HubSpot WAF 403 block pages as verified tokens#5170
pasmud wants to merge 1 commit into
trufflesecurity:mainfrom
pasmud:fix/5164-hubspot-403-verification

Conversation

@pasmud

@pasmud pasmud commented Jul 31, 2026

Copy link
Copy Markdown

Summary

The v2 HubSpot API key detector reports any 403 response as a verified token. HubSpot's WAF returns 403 with an HTML block page for requests it decides to block, and that can happen for bogus tokens too. So random pat-na1-* strings end up reported as verified secrets.

Changes

  • pkg/detectors/hubspot_apikey/v2/apikey.go: in verifyToken, a 403 is only treated as verified when the response is a HubSpot API JSON error (contains correlationId). HTML block pages now return unverified.
  • pkg/detectors/hubspot_apikey/v2/apikey_test.go: added TestVerifyToken covering 200, 401, API JSON 403, and WAF HTML 403 cases.

Test plan

  • go test ./pkg/detectors/hubspot_apikey/... passes.
  • go vet ./pkg/detectors/hubspot_apikey/... and go build ./... pass.
  • Live check: a bogus pat-na1- token gets a 401 INVALID_AUTHENTICATION from the API and is reported unverified, same as before.

Notes

The v1 detector uses a different endpoint (contacts/v1/lists?hapikey=) which already returns 401 for invalid keys, so it needed no change.

Fixes #5164


Note

Low Risk
Scoped to HubSpot v2 verification logic and tests; reduces false positives without changing auth or data paths.

Overview
Fixes false positives where the v2 HubSpot API key detector marked any 403 as a verified token. HubSpot’s WAF can return 403 with an HTML block page for invalid or blocked requests, not only when a real token lacks permission.

verifyToken now reads the 403 body and only counts the token as verified when the response looks like HubSpot API JSON (presence of correlationId). WAF HTML pages are treated as unverified.

Adds TestVerifyToken with a stub HTTP transport for 200, 401, permission-denied JSON 403, and WAF HTML 403.

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

The v2 HubSpot detector marked any 403 response as a verified token. HubSpot's WAF returns 403 with an HTML block page for requests it does not like, including requests with bogus tokens. Only API error responses (JSON) are now treated as verified.
@pasmud
pasmud requested a review from a team July 31, 2026 13:38
@pasmud
pasmud requested a review from a team as a code owner July 31, 2026 13:38
@CLAassistant

CLAassistant commented Jul 31, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

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.

HubSpot API key detection reports any pat-na1-* string as verified

2 participants