Skip to main content
bagel
Toggle Dark/Light/Auto mode Toggle Dark/Light/Auto mode Toggle Dark/Light/Auto mode Back to homepage

Detectors

Bagel uses detectors to identify exposed secrets in the content scanned by probes. Each detector specializes in a specific type of credential and uses regular expressions and heuristics to minimize false positives.

Available Detectors

DetectorDescriptionSeverity
GitHub TokenGitHub PATs and app tokensCritical
SSH Private KeySSH private keys (encrypted/unencrypted)Critical/Low
Cloud CredentialsAWS, GCP, Azure credentialsCritical
AI ServiceOpenAI, Anthropic, HuggingFace keysCritical
Generic API KeyHigh-entropy secretsHigh
HTTP AuthBearer tokens, Basic auth, API keysCritical
JWTJWT and JWE tokensCritical
NPM TokenNPM authentication tokensCritical

How Detectors Work

  1. Pattern Matching - Each detector uses regex patterns specific to its credential type
  2. Validation - Additional checks (entropy, format) reduce false positives
  3. Fingerprinting - Detected secrets are SHA-256 hashed for deduplication without storing actual values
  4. Context Enrichment - Findings include probe context (file, line number, environment variable name)

Severity Levels

LevelDescription
CriticalActive credentials that provide direct access to systems
HighLikely credentials or high-entropy secrets
MediumConfiguration issues that could lead to exposure
LowInformational findings or encrypted credentials

Detection vs. Exposure

Bagel reports metadata about secrets, never the actual values:

{
  "id": "github-token-classic-pat",
  "severity": "critical",
  "path": "env:GITHUB_TOKEN",
  "metadata": {
    "fingerprint": "sha256:a1b2c3..."
  }
}

The fingerprint allows you to track and deduplicate findings without exposing the secret.

False Positives

Detectors include safeguards to reduce false positives:

  • Generic API Key - Filters placeholder values and environment variable references
  • SSH Keys - Differentiates encrypted from unencrypted keys
  • Cloud Credentials - Uses specific prefixes and formats per provider

If you encounter false positives, please open an issue with sanitized examples.

Adding Custom Detectors

Bagel’s detector system is extensible. See the source code for implementation examples.