GraphQL Cop:一款针对GraphQL API的安全审计工具

admin 2024年11月26日22:48:32评论12 views字数 3424阅读11分24秒阅读模式

GraphQL Cop:一款针对GraphQL API的安全审计工具

关于GraphQL Cop

GraphQL Cop是一个小型 Python 实用程序,用于针对 GraphQL API 运行常见的安全测试。GraphQL Cop非常适合在 GraphQL 中运行 CI/CD 检查。

GraphQL Cop:一款针对GraphQL API的安全审计工具

GraphQL Cop是一个轻量级工具,并且涵盖了GraphQL中有趣的安全问题。值得一提的是,GraphQL Cop允许广大研究人员通过在任何已发现的漏洞上提供cURL命令来重现调查结果。

功能介绍

当前版本的GraphQL Cop支持执行下列检测:

1、别名过载(DoS);

2、批量查询(DoS);

3、基于 GET 的查询(CSRF);

4、使用 urlencoded 负载的 POST 查询(CSRF);

5、GraphQL 跟踪/调试模式(信息泄漏);

6、字段重复(DoS);

7、字段建议(信息泄露);

8、GraphiQL(信息泄露);

9、自省(信息泄露);

10、指令重载(DoS);

11、使用内省(DoS)的循环查询;

12、通过 GET 方法支持变异(CSRF);

工具要求

requests==2.25.1

simplejson==3.17.6

termcolor==2.2.0

PySocks==1.7.1

工具安装

由于该工具基于Python 3开发,因此我们首先需要在本地设备上安装并配置好最新版本的Python 3环境。

接下来,广大研究人员可以直接使用下列命令将该项目源码克隆至本地:

git clone https://github.com/dolevf/graphql-cop.git

然后切换到项目目录中,使用下列命令在指定的目录中创建一个虚拟环境,然后激活虚拟环境,并安装requirements.txt 中列出的所有 Python 包:

cd graphql-cop
python3 -m venv path/to/venv
source path/to/venv/bin/activate
python3 -m pip install -r requirements.txt
工具使用
$ python graphql-cop.py -h

 

Usage: graphql-cop.py -t http://example.com -o json

 

Options:

  -h, --help            显示此帮助消息并退出

  -t URL, --target=URL   目标URL地址,如果没有提供GraphQL路径,GraphQL Cop将迭代一系列常见GraphQL路径

  -H HEADER, --header=HEADER     将Header(s) 添加到请求中

  -o FORMAT, --output=FORMAT      输出json格式

  -f, --force             在无法检测到GraphQL时强制扫描

  -d, --debug          为调试添加一个带有测试名称的Header

  -x PROXY, --proxy=PROXY   HTTP(S)代理URL,格式为http://user:pass@host:port

-v, --version         打印工具当前版本

-T, --tor            启用Tor代理

工具运行演示

测试网站:

$ python3 graphql-cop.py -t https://mywebsite.com/graphql

 

                GraphQL Cop 1.1

           Security Auditor for GraphQL

            Dolev Farhi & Nick Aleks

 

Starting...

[HIGH] Introspection Query Enabled (Information Leakage)

[LOW] GraphQL Playground UI (Information Leakage)

[HIGH] Alias Overloading with 100+ aliases is allowed (Denial of Service)

[HIGH] Queries are allowed with 1000+ of the same repeated field (Denial of Service)

测试网站,转储为可解析的 JSON 输出,cURL 复现命令:

python3 graphql-cop.py -t https://mywebsite.com/graphql -o json

 

 {'curl_verify': 'curl -X POST -H "User-Agent: graphql-cop/1.2" -H '

                 '"Accept-Encoding: gzip, deflate" -H "Accept: */*" -H '

                 '"Connection: keep-alive" -H "Content-Length: 33" -H '

                 '"Content-Type: application/json" -d '{"query": "query { '

                 '__typename }"}' 'http://localhost:5013/graphql'',

  'description': 'Tracing is Enabled',

  'impact': 'Information Leakage',

  'result': False,

  'severity': 'INFO',

  'color': 'green',

  'title': 'Trace Mode'},

 {'curl_verify': 'curl -X POST -H "User-Agent: graphql-cop/1.2" -H '

                 '"Accept-Encoding: gzip, deflate" -H "Accept: */*" -H '

                 '"Connection: keep-alive" -H "Content-Length: 64" -H '

                 '"Content-Type: application/json" -d '{"query": "query { '

                 '__typename @aa@aa@aa@aa@aa@aa@aa@aa@aa@aa }"}' '

                 "'http://localhost:5013/graphql'",

  'description': 'Multiple duplicated directives allowed in a query',

  'impact': 'Denial of Service',

  'result': True,

  'severity': 'HIGH',

  'color': 'red',

  'title': 'Directive Overloading'}]

graphql-cop通过代理(例如,监听 127.0.0.1:8080 的 Burp Suite)和自定义标头(例如,授权)测试网站:

$ python3 graphql-cop.py -t https://mywebsite.com/graphql --proxy=http://127.0.0.1:8080 --header '{"Authorization": "Bearer token_here"}'

 

                GraphQL Cop 1.2

           Security Auditor for GraphQL

            Dolev Farhi & Nick Aleks

 

Starting...

[HIGH] Introspection Query Enabled (Information Leakage)

[LOW] GraphQL Playground UI (Information Leakage)

[HIGH] Alias Overloading with 100+ aliases is allowed (Denial of Service)
[HIGH] Queries are allowed with 1000+ of the same repeated field (Denial of Service)
许可证协议

本项目的开发与发布遵循MIT开源许可协议。

项目地址

GraphQL Cop:【GitHub传送门】

原文始发于微信公众号(FreeBuf):GraphQL Cop:一款针对GraphQL API的安全审计工具

 

免责声明:文章中涉及的程序(方法)可能带有攻击性,仅供安全研究与教学之用,读者将其信息做其他用途,由读者承担全部法律及连带责任,本站不承担任何法律及连带责任;如有问题可邮件联系(建议使用企业邮箱或有效邮箱,避免邮件被拦截,联系方式见首页),望知悉。
  • 左青龙
  • 微信扫一扫
  • weinxin
  • 右白虎
  • 微信扫一扫
  • weinxin
admin
  • 本文由 发表于 2024年11月26日22:48:32
  • 转载请保留本文链接(CN-SEC中文网:感谢原作者辛苦付出):
                   GraphQL Cop:一款针对GraphQL API的安全审计工具https://cn-sec.com/archives/3441619.html
                  免责声明:文章中涉及的程序(方法)可能带有攻击性,仅供安全研究与教学之用,读者将其信息做其他用途,由读者承担全部法律及连带责任,本站不承担任何法律及连带责任;如有问题可邮件联系(建议使用企业邮箱或有效邮箱,避免邮件被拦截,联系方式见首页),望知悉.

发表评论

匿名网友 填写信息