id: retool-postmessage-xss

info:
  name: Retool Self-Hosted - postMessage XSS via Custom Component Collections
  author: DhiyaneshDk
  severity: high
  description: |
    Retool Self-Hosted versions 3.284.0 through 3.284.11 contain a cross-site scripting (XSS) vulnerability in the custom component collections iframe handler. The postMessage event listener in custom-component-collections.html accepts messages from any origin without validation and dynamically imports the received code via data:text/javascript URLs, allowing arbitrary JavaScript execution in the Retool instance origin context.
  reference:
    - https://docs.retool.com/releases
    - https://docs.retool.com/changelog/disclosures/custom-component-xss
  metadata:
    max-request: 2
    vendor: retool
    product: retool
    shodan-query: title:"Retool"
    fofa-query: title="Retool"
  tags: retool,xss,postmessage,vuln

http:
  - method: GET
    path:
      - "{{BaseURL}}/custom-component-collections.html"

    matchers:
      - type: dsl
        dsl:
          - 'status_code == 200'
          - 'contains_all(body, "Custom Component", "custom-component-collections")'
        condition: and
        internal: true

    extractors:
      - type: regex
        name: js-bundle
        part: body
        group: 1
        regex:
          - '["'']/?(libs/custom-component-collections[^"'']+\.js)["'']'
        internal: true

  - method: GET
    path:
      - "{{BaseURL}}/{{js-bundle}}"

    matchers:
      - type: dsl
        dsl:
          - 'status_code == 200'
          - 'contains_all(body, "customComponentCode", "data:text/javascript", "addEventListener(\"message\"")'
        condition: and
# digest: 4a0a004730450220229db5e3c267581dc3fa00456d7b49def7b8f882a4bed0fb625ec4cbf77bb4d4022100e764b2c995b5008a97503eea80aae799a5a3ee2efbd2bb8ec68993c143aa1b01:922c64590222798bb761d5b6d8e72950