id: stripe-secret-key

info:
  name: Stripe Secret Key Disclosure
  author: Ice3man
  severity: high
  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: 4b0a004830460221009c6a1b454ed1ab1ea7c7c916a8a6efc3933a0ac4b44d0d61fad0f5d79966487f0221008ce12822e619eac8364e33b193e2b97a3db1874862f22bd4243748107dd0e7a4:922c64590222798bb761d5b6d8e72950