id: stackhawk-api

info:
  name: StackHawk API Key
  author: DhiyaneshDK
  severity: high
  reference:
    - https://github.com/praetorian-inc/noseyparker/blob/main/crates/noseyparker/data/default/builtin/rules/stackhawk.yml
    - https://apidocs.stackhawk.com/reference/login
  metadata:
    verified: true
    max-request: 1
  tags: stackhawk,token,exposure

flow: http(1) && http(2)

http:
  - method: GET
    path:
      - "{{BaseURL}}"

    matchers:
      - type: regex
        part: body
        name: token
        regex:
          - '\b(hawk\.[0-9A-Za-z_-]{20}\.[0-9A-Za-z_-]{20})\b'
        internal: true

  - raw:
      - |
        @Host: https://api.stackhawk.com:443
        GET /api/v1/auth/login HTTP/1.1
        Host: api.stackhawk.com
        X-ApiKey: {{token}}
        Accept: application/json

    disable-path-automerge: true
    matchers:
      - type: dsl
        dsl:
          - 'status_code == 200'
          - 'contains(body, "token")'
          - 'contains(content_type, "application/json")'
        condition: and

    extractors:
      - type: dsl
        dsl:
          - token
# digest: 4a0a00473045022100afa8ef1ce30cafe34e4f48f21c08b8c36edcc419b1428fddad3ad0913a5179aa022030edd6062efec8b697aeb972f269b3a38c4375e78b7412e6e2cae0860d294bce:922c64590222798bb761d5b6d8e72950