Skip to content

Conversation

@shahzadhaider1
Copy link
Contributor

Summary

Adds a new detector for JFrog Artifactory Reference Tokens. Unlike JWT tokens (which start with eyJ), reference tokens are base64-encoded strings with a predictable structure:

reftkn:01:<expiry>:<random_data>

When base64-encoded, this always produces a token starting with cmVmdGtu.

Detection

Regex pattern:

\b(cmVmdGtu[A-Za-z0-9]{56})\b
  • Fixed prefix: cmVmdGtu (8 chars): base64 encoding of "reftkn"
  • Variable suffix: 56 alphanumeric characters
  • Total length: exactly 64 characters

Keyword: cmVmdGtu

Verification

Tokens are verified against the JFrog Access API:

GET https://<host>/access/api/v1/tokens/me
Authorization: Bearer <token>

This endpoint returns token metadata if valid. Available since Artifactory 7.53.1.

Response handling:

Status Meaning Result
200 + JSON Valid token Verified
200 + HTML Invalid subdomain (redirects to login page) Skip host
403 Valid token, insufficient permissions Verified
401 Invalid or expired token Not verified
404 Endpoint not found (old Artifactory version) Verification error

References

Checklist:

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

@shahzadhaider1 shahzadhaider1 requested a review from a team January 21, 2026 08:03
@shahzadhaider1 shahzadhaider1 requested review from a team as code owners January 21, 2026 08:03
for token := range uniqueTokens {
for url := range uniqueUrls {
if invalidHosts.Exists(url) {
delete(uniqueUrls, url)
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't see any value with deleting the url from uniqueUrls. Also it might lead to unexpected behaviors if we mutate the slice we're looping over.

Copy link
Contributor

@mustansir14 mustansir14 left a comment

Choose a reason for hiding this comment

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

LGTM.

@shahzadhaider1 shahzadhaider1 changed the title added detector for artifactory reference tokens Added detector for JFrog Artifactory Reference Tokens Jan 21, 2026
@shahzadhaider1 shahzadhaider1 linked an issue Jan 28, 2026 that may be closed by this pull request
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.

for url := range uniqueUrls {
if invalidHosts.Exists(url) {
delete(uniqueUrls, url)
continue
Copy link

Choose a reason for hiding this comment

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

Map mutation during iteration causes missed token-URL combinations

Medium Severity

The delete(uniqueUrls, url) call modifies the uniqueUrls map while iterating over it in a nested loop. When multiple tokens exist, the first token that encounters a URL in invalidHosts removes it from uniqueUrls, causing all subsequent tokens to skip that URL entirely. This results in missed token-URL combinations. The deletion is also unnecessary since invalidHosts.Exists(url) already handles filtering on each iteration.

Fix in Cursor Fix in Web

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 support for Artifactory Reference Token

2 participants