Skip to content

Update Cloudflare detector patterns for 2026+ credential formats#4830

Open
nkcmr wants to merge 2 commits intotrufflesecurity:mainfrom
nkcmr:nick/update-cf-credential-pats
Open

Update Cloudflare detector patterns for 2026+ credential formats#4830
nkcmr wants to merge 2 commits intotrufflesecurity:mainfrom
nkcmr:nick/update-cf-credential-pats

Conversation

@nkcmr
Copy link
Copy Markdown

@nkcmr nkcmr commented Mar 23, 2026

Context/Background

Cloudflare is rolling out new prefixed credential formats in 2026. The legacy patterns were too broad (wrong char classes, fixed lengths) and the new formats (cfk_, cfut_, cfat_) are self-identifying via prefix, so they do not need keyword proximity matching.

Additionally, CA keys (Service Keys) are now deprecated.

Changes in this commit

  • cloudflareglobalapikey: fix legacy pattern to lowercase hex [a-f0-9]{37,45}, add cfk_ v2 pattern and keyword
  • cloudflareapitoken: add cfut_/cfat_ v2 pattern with combined regex cf[ua]t_, add keywords, route cfat_ verification through the account-scoped /accounts/:id/tokens/verify endpoint (extracting account IDs from surrounding data)
  • cloudflarecakey: add deprecation notice with changelog link
  • Update tests for all changed detectors

Description:

Explain the purpose of the PR.

Checklist:

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

Note

Medium Risk
Updates secret-matching regexes and verification behavior for Cloudflare tokens/keys, which could change detection/verification outcomes and increase verification requests (especially for cfat_ tokens when many account IDs are present). Scope is limited to Cloudflare detectors and their tests.

Overview
Updates Cloudflare detectors to recognize new 2026+ prefixed credentials and tighten legacy matching. cloudflareapitoken now detects cfut_/cfat_ tokens without keyword proximity and verifies cfat_ tokens via account-scoped endpoints by pairing tokens with any 32-hex account IDs found in the surrounding data.

cloudflareglobalapikey refines the legacy global API key regex to lowercase hex with variable length, adds cfk_ detection without keyword proximity, and expands keyword prefiltering accordingly. cloudflarecakey adds a deprecation notice for Origin CA (Service) keys, and tests are updated to cover the new patterns.

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

 ## Context/Background

Cloudflare is rolling out new prefixed credential formats in 2026.
The legacy patterns were too broad (wrong char classes, fixed lengths)
and the new formats (`cfk_`, `cfut_`, `cfat_`) are self-identifying
via prefix, so they do not need keyword proximity matching.

Additionally, CA keys (Service Keys) are now deprecated.

 ## Changes in this commit

- cloudflareglobalapikey: fix legacy pattern to lowercase hex
  `[a-f0-9]{37,45}`, add `cfk_` v2 pattern and keyword
- cloudflareapitoken: add `cfut_`/`cfat_` v2 pattern with combined
  regex `cf[ua]t_`, add keywords, route `cfat_` verification through
  the account-scoped `/accounts/:id/tokens/verify` endpoint
  (extracting account IDs from surrounding data)
- cloudflarecakey: add deprecation notice with changelog link
- Update tests for all changed detectors
@nkcmr nkcmr requested a review from a team March 23, 2026 14:48
@nkcmr nkcmr requested a review from a team as a code owner March 23, 2026 14:48
@CLAassistant
Copy link
Copy Markdown

CLAassistant commented Mar 23, 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

@amanfcp
Copy link
Copy Markdown
Contributor

amanfcp commented Mar 30, 2026

Hey @nkcmr can you also attach some doc links which state the mentioned credential format changes?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This requires a v2. See this

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.

3 participants