id: stripe-secret-key

info:
  name: Stripe Secret Key Disclosure
  author: Ice3man
  severity: high
  reference:
    - https://stripe.com/docs/keys
  metadata:
    max-request: 2
    verified: true
  tags: exposure,token,stripe

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

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

    matchers:
      - type: regex
        part: body
        name: token
        regex:
          - 'sk_(?:live|test)_[0-9a-zA-Z]{24}'
        internal: true

  - raw:
      - |
        @Host: https://api.stripe.com:443
        GET /v1/charges?limit=1 HTTP/1.1
        Host: api.stripe.com
        Authorization: Bearer {{token}}

    disable-path-automerge: true
    matchers:
      - type: dsl
        dsl:
          - 'status_code == 200'
          - 'contains(body, "billing_details") && contains(body, "balance_transaction")'
        condition: and

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