id: slack-bot-token

info:
  name: Slack Bot token
  author: nadino
  severity: high
  reference:
    - https://api.slack.com/authentication/token-types
  metadata:
    max-request: 1
    verified: true
  tags: exposure,token,slack

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

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

    matchers:
      - type: regex
        part: body
        name: token
        regex:
          - 'xoxb-[0-9A-Za-z\\-]{52}'
          - '(xoxb-[0-9]{10,13}\-[0-9]{10,13}[a-zA-Z0-9-]*)'
        internal: true

  - raw:
      - |
        @Host: https://slack.com:443
        POST /api/auth.test?pretty=1 HTTP/1.1
        Host: slack.com
        Origin: https://api.slack.com
        Content-Type: multipart/form-data; boundary=----WebKitFormBoundaryDL3VHEC7cFaxeAhK

        ------WebKitFormBoundaryDL3VHEC7cFaxeAhK
        Content-Disposition: form-data; name="content"

        null
        ------WebKitFormBoundaryDL3VHEC7cFaxeAhK
        Content-Disposition: form-data; name="token"

        {{token}}
        ------WebKitFormBoundaryDL3VHEC7cFaxeAhK--


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

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