Skip to content

security/leaked-secrets: raise confidence by decoding the token, not by calling the provider #361

Closed

Description

@nc9

We must never verify a third party's credential against the provider from a website audit. Several formats carry enough structure to confirm or downgrade a hit offline:

  • AWS access key id: the account id is encoded in the id (base32 of the suffix); a decodable id with an AKIA/ASIA prefix is a real key shape, a non-decodable one is noise. Report the account id in the finding.
  • GitHub tokens (ghp_, gho_, ghu_, ghs_, ghr_, github_pat_): the last 6 characters are a CRC32 checksum of the body. Checksum mismatch → drop.
  • JWTs: decode header and payload. role: service_role (Supabase) or admin scopes → high; role: anon → public; expired exp → downgrade to info; a first-party session token (no known issuer) → medium at most, never labelled Supabase.
  • Algolia secured API keys: the base64 tail decodes to the restriction params; a key with restrictIndices/validUntil is a scoped search key (public), one without restrictions that is 32 hex is an admin-shaped key.
  • Slack tokens: xoxb/xoxp/xoxe structure with numeric segments; Stripe keys: sk/rk/pk × live/test gives the tier directly.
  • Sentry DSN: the host and project id say which org it belongs to; a DSN pointing at a different org than the site's own is worth a note.

Each decoder produces extra fields on the finding (account id, expiry, role, restrictions) that the report and MCP surfaces can show.

Acceptance Criteria

  • An AKIA… id whose suffix does not decode to an account id is not reported as high
  • A ghp_ token with a wrong checksum is not reported; a correct one reports high with no provider call made (assert no network in the test)
  • A Supabase JWT with role: service_role reports high; role: anon reports public; an expired JWT reports info
  • An Algolia key with restriction params reports public; a 32-hex admin-shaped key near the algolia keyword reports medium
  • Finding extra data is present in the JSON report and the get_report MCP output for each decoded case

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions