generic.secrets.gitleaks.github-fine-grained-pat.github-fine-grained-pat

profile photo of semgrepsemgrep
Author
unknown
Download Count*

A gitleaks github-fine-grained-pat was detected which attempts to identify hard-coded credentials. It is not recommended to store credentials in source-code, as this risks secrets being leaked and used by either an internal or external malicious adversary. It is recommended to use environment variables to securely provide credentials or retrieve credentials from a secure vault or HSM (Hardware Security Module).

Run Locally

Run in CI

Defintion

rules:
  - id: github-fine-grained-pat
    message: A gitleaks github-fine-grained-pat was detected which attempts to
      identify hard-coded credentials. It is not recommended to store
      credentials in source-code, as this risks secrets being leaked and used by
      either an internal or external malicious adversary. It is recommended to
      use environment variables to securely provide credentials or retrieve
      credentials from a secure vault or HSM (Hardware Security Module).
    languages:
      - regex
    severity: INFO
    metadata:
      likelihood: LOW
      impact: MEDIUM
      confidence: LOW
      category: security
      cwe:
        - "CWE-798: Use of Hard-coded Credentials"
      cwe2021-top25: true
      cwe2022-top25: true
      owasp:
        - A07:2021 - Identification and Authentication Failures
      references:
        - https://cheatsheetseries.owasp.org/cheatsheets/Secrets_Management_Cheat_Sheet.html
      source-rule-url: https://github.com/zricethezav/gitleaks/tree/master/cmd/generate/config/rules
      subcategory:
        - vuln
      technology:
        - gitleaks
      license: Commons Clause License Condition v1.0[LGPL-2.1-only]
      vulnerability_class:
        - Hard-coded Secrets
    patterns:
      - pattern-regex: github_pat_[0-9a-zA-Z_]{82}

Examples

github-fine-grained-pat.go

// ruleid: github-fine-grained-pat
github_api_token = "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"
github_api_token = "gho_gkp19cjcgv0b0akt2skq9qhk4bswzrzagerz"
github_api_token = "ghu_d6iigas9ayzz1ru2nkemcf51uf7giekye10d"
github_api_token = "ghs_wfnmo2sxr5b9e3m2tucw9zgs8msiwrt5dm3k"
github_api_token = "ghr_oxjwkll093ocn52a6592ka7ofod5517bhmx9"