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,vuln

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: 490a0046304402205cdce695aa62aaeccc771756d2b0878d7d359cf2b440277cd0848d547a6eca2302202fe986cf30f15c64b10b6e796b9c2fb371a09c9a2b361198c0d11cd44703c8b2:922c64590222798bb761d5b6d8e72950