generic.secrets.security.detected-generic-secret.detected-generic-secret

profile photo of semgrepsemgrep
Author
5,361
Download Count*

Generic Secret detected

Run Locally

Run in CI

Defintion

rules:
  - id: detected-generic-secret
    patterns:
      - pattern-regex: "[sS][eE][cC][rR][eE][tT][:=
          \\t]*['|\\\"]?(?<SECRET>[0-9a-zA-Z]{32,45})['|\\\"]?"
      - metavariable-analysis:
          analyzer: entropy
          metavariable: $SECRET
    languages:
      - regex
    message: Generic Secret detected
    severity: ERROR
    metadata:
      cwe:
        - "CWE-798: Use of Hard-coded Credentials"
      source-rule-url: https://github.com/dxa4481/truffleHogRegexes/blob/master/truffleHogRegexes/regexes.json
      category: security
      technology:
        - secrets
      confidence: LOW
      owasp:
        - A07:2021 - Identification and Authentication Failures
      references:
        - https://owasp.org/Top10/A07_2021-Identification_and_Authentication_Failures
      cwe2022-top25: true
      cwe2021-top25: true
      subcategory:
        - audit
      likelihood: LOW
      impact: MEDIUM
      license: Commons Clause License Condition v1.0[LGPL-2.1-only]
      vulnerability_class:
        - Hard-coded Secrets

Examples

detected-generic-secret.txt

# ruleid: detected-generic-secret
secret=1234567890123456789012345678901234567890

# ruleid: detected-generic-secret
SECRET: 123567890123456789012345678901234567890

# ok: detected-generic-secret
secretary: 123567890123456789012345678901234567890s