Repository navigation
feat(detectors): add Infisical service token detector - #5445
dustin-decker merged 4 commits into
Conversation
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 2 potential issues.
Reviewed by Cursor Bugbot for commit d1c8b96. Configure here.
Infisical is a widely used open-source secrets management platform, and its service tokens (st.<id>.<secret>) are bearer credentials that grant read/write access to secrets in their scoped environments. TruffleHog had no detector for this format, so leaked Infisical tokens were silently missed. The token shape is confirmed by Infisical's docs and source: st.<uuid>.<32 lowercase hex> (secret = crypto.randomBytes(16).hex()). Adds DetectorType Infisical (1074), a new infisical scanner with keyword st., and verification via GET /api/v3/secrets/raw (unknown token IDs return 404, valid tokens pass auth and return 400 for the missing workspaceId param). Fixes trufflesecurity#5444 Signed-off-by: Varshith Puli <pulivarshit@gmail.com>
…egion-aware Verification only treated 2xx and 400 as verified and every other status as a determinate miss, so rate limits (429), server errors (5xx) and 403 from a scoped-but-valid token silently read as "not a secret" and could be dropped by --only-verified. These statuses are now indeterminate: verification records a verification error via SetVerificationError instead of a silent miss, following the (bool, error) convention used by sibling detectors (datadogapikey, humioapitoken). Verification also only targeted https://app.infisical.com (Cloud US). Cloud regions are isolated, so a valid EU token read as 404/invalid. The scanner now implements CloudProvider/EndpointCustomizer (humioapitoken pattern): the US host stays primary, https://eu.infisical.com is tried next, and the verifying endpoint is recorded in ExtraData. Self-hosted instances keep working via configured endpoints or URLs found in scanned data. Tests: httptest-based coverage for the status matrix (2xx/400 verify; 401/404 determinate miss; 403/429/5xx/unexpected indeterminate with verification error), the US->EU region fallback, and the 400-from-missing-workspaceId behavior. Replaces the previous live-network verification test. Signed-off-by: Varshith Puli <pulivarshit@gmail.com>
c1d1db8 to
84b1917
Compare
|
Checking in on the Infisical service token detector. The workflow runs are still parked at the first-time-contributor approval step; approving them would let CI run on the current head. The two Cursor Bugbot findings from the earlier review are fixed on this head. Happy to adjust anything else. |
|
Hi team, friendly follow-up: the workflow runs on this PR (Smoke, Test, CodeQL, Lint, Scan for secrets, Performance Test) are still parked at action_required awaiting first-time-contributor approval. Approving them would let CI run on the current head. Thanks! |
Verify with GET /api/v2/service-token instead of the deprecated raw secrets route, which can return plaintext project secrets. Only HTTP 200 verifies; 401 and 404 are invalid; other statuses and transport errors are indeterminate. Capture the optional fourth dashboard segment so the full token is retained in Raw and SecretParts, send only the first three components as the Bearer value, and deduplicate identical tokens per chunk. Keep an earlier endpoint error when a later endpoint misses. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Resolve the detector_type enum conflict with Fireworks (trufflesecurity#5447) by keeping Infisical = 1075 and Fireworks = 1076, and regenerate detector_type.pb.go with `make protos` (trufflesecurity/protos:1.22). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Thanks for the contribution! |

Summary
Adds a new detector for Infisical service tokens (
st.<id>.<secret>), the bearer credentials Infisical issues for programmatic access to secrets. TruffleHog previously had no coverage for this format, so leaked Infisical tokens were silently missed.Infisical is a widely adopted open-source secrets management platform (a popular HashiCorp Vault alternative), and service tokens are its current widely-used auth method for CI/CD pipelines and services. A leaked token grants read/write access to the secrets in its scoped environments and paths, which makes this a high-impact blind spot: these tokens live in env files and CI configs, exactly the places TruffleHog scans.
Fixes #5444.
Root cause
There was no
infisicalscanner and noDetectorTypefor it. The distinctivest.<uuid>.<32 hex>shape matched nothing in the existing detector set.Evidence for the format
From Infisical's own docs (https://infisical.com/docs/documentation/platform/token):
Confirmed in Infisical's source (
Infisical/infisical,backend/src/services/service-token/service-token-service.ts):The token ID is a UUID (migration
20231225072545_service-token.ts:t.string("id", 36).primary().defaultTo(knex.fn.uuid())).The dashboard appends a fourth segment of 32 lowercase hex characters before showing the token (
frontend/src/hooks/api/serviceTokens/queries.tsx), and the official CLI rejects tokens without it. The backend authenticates with only the first three segments.Detection pattern:
\b((st\.[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}\.[0-9a-f]{32})(?:\.[0-9a-f]{32})?)\b, keywordst.. The full three-part or four-part token as found is kept inRawandSecretParts["key"]. Identical tokens in a chunk are reported and verified once.Verification
GET /api/v2/service-tokenwithAuthorization: Bearer st.<id>.<secret>(only the first three segments are sent). This route returns only the token's metadata; the official CLI calls it to read token details. The earlier/api/v3/secrets/rawroute is not used because, for a token with one exact scope, it returns plaintext secret values and records a secret read in the audit log.Requests go to
https://app.infisical.comandhttps://eu.infisical.complus any configured endpoints (for self-hosted instances). URLs found in scanned data are never used. From Infisical's auth code (fnValidateServiceTokenin the same service file, invoked by the globalinjectIdentityhook):SetVerificationError. An error from one endpoint is kept when a later endpoint returns a clean miss.I could not exercise verification against a live token (no Infisical account in this environment), so the test asserts that a synthetic correctly-shaped token is found but not marked verified.
Test results
go test ./pkg/detectors/infisical/: PASS (pattern tests for three-part and four-part tokens and invalid shapes, the status matrix, region fallback, error retention across endpoints, and duplicate-token deduplication; all against local test servers with synthetic tokens).go test ./pkg/engine/defaults/: PASS (includesTestAllDetectorTypesAreInDefaultList).go test ./pkg/config/: PASS.go buildon the touched packages andgo veton the new detector: clean.gofmt: clean.Known limits
st.service token format is covered. Infisical's newer machine-identity auth (universal auth client ID/secret) is a separate credential shape and is out of scope here./api/v2/service-token(200 valid, 401/404 invalid). That route is marked deprecated, so future removal or status-code changes would require updating the verifier.detector_type.pb.gowas regenerated withmake protosafter mergingmain(which addedFireworks = 1076).Checklist
DetectorType(Infisical = 1075) added toproto/detector_type.protoand the generated code.pkg/engine/defaults/defaults.go, feature-flagged (InfisicalDetectorEnabled, enabled inmain.go).SecretPartspopulated on every result.Note
Medium Risk
Verification sends discovered bearer tokens to Infisical (or custom) hosts over the network; behavior is additive but touches high-value secrets-management credentials.
Overview
Adds Infisical service token detection for credentials shaped like
st.<uuid>.<32 hex>, including optional fourth segments as shown in the Infisical dashboard, with keyword prefilterst..When verification is on, tokens are checked via
GET /api/v2/service-token(metadata only, not secret values) against US/EU Infisical Cloud and any custom verifier endpoints, trying regions until one succeeds. HTTP handling treats 401/404 as invalid, 200 as verified, and 403/429/5xx (and other unexpected codes) as indeterminate with verification errors preserved across region attempts.Wiring adds
DetectorType_Infisical(1075), registers the scanner behindInfisicalDetectorEnabled(enabled inmain.go), and includes broad unit tests for patterns, status codes, region fallback, and deduplication.Reviewed by Cursor Bugbot for commit fdc4a39. Bugbot is set up for automated code reviews on this repo. Configure here.