Skip to content

Conversation

thevilledev
Copy link

NOTE: I'll keep this as a draft until #1299 is merged, since this implementation should use the same common JWT utilities.

Detection:

  • HCP client credentials exposed as env-style pairs: HCP_CLIENT_ID (32 chars, alphanumeric) and HCP_CLIENT_SECRET (64 chars, [A-Za-z0-9._~-]). These tokens cannot be identified otherwise since there's no common prefix/suffix. Pairs the nearest ID/secret within a small window (256 bytes); emits singletons if only one present.
  • HCP access tokens (JWT) identified via bounded base64url regex and validated by claims.

Validation:

  • Client credentials validated via OAuth2 client credentials token exchange. If a token can be generated with the given ID and Secret it is considered valid. POSTs to token endpoint https://auth.hashicorp.com/oauth/token to validate; 200 => VALID, 400/401 => INVALID, other => FAILED.
  • Access tokens validated by calling the HCP caller-identity endpoint. GETs https://api.cloud.hashicorp.com/iam/2019-12-10/caller-identity with a bearer token; 200 => VALID, 401 => INVALID, other => FAILED.

Documentation:

Fixes #1253

Signed-off-by: Ville Vesilehto <ville@vesilehto.fi>
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.

PRP: Secret extractor for HashiCorp Cloud Platform API keys
1 participant