id: graphql-get-method

info:
  name: GraphQL CSRF / GET method
  author: Dolev Farhi
  severity: info
  description: |
    Cross Site Request Forgery happens when an external website gains ability to make API calls impersonating an user if he visits the website while being authenticated to your API.
    Allowing API calls through GET requests can lead to CSRF attacks, because cookies are added automatically to GET requests by the browser.
  reference:
    - https://graphql.org/learn/serving-over-http/#get-request
    - https://github.com/dolevf/Damn-Vulnerable-GraphQL-Application
    - https://cheatsheetseries.owasp.org/cheatsheets/GraphQL_Cheat_Sheet.html
    - https://graphql.security/
  metadata:
    max-request: 2
  tags: graphql,misconfig,vuln

http:
  - method: GET
    path:
      - "{{BaseURL}}/graphql?query={__typename}"
      - "{{BaseURL}}/api/graphql?query={__typename}"

    stop-at-first-match: true

    matchers-condition: and
    matchers:
      - type: word
        part: body
        words:
          - '"query"'
          - '"data"'
          - '"__typename"'
        case-insensitive: true
        condition: and

      - type: word
        part: header
        words:
          - "application/json"
# digest: 4a0a00473045022010bc8004ad10ff0f5345312c9327204c7db9983b024b8b35e4726e6e5f91a25a022100c1a338bcd1e565c1b08fc3758a023f26d30ad9bbd3964d2a98cbc00bfab4f5b3:922c64590222798bb761d5b6d8e72950