正文
通常graphql接口位于类似 www.example.com/graphql
的地方
这里的接口如下所示:(其实这种情况在国外的网站经常会看到)
首先,检查一下目标是否启用了自省模式(可以参考以前本公众号中的文章: 漏洞赏金猎人笔记-GraphQL-IV ),如果在GraphQL中启用了自省,则允许客户端查询并检索关于GraphQL API中可用类型、字段和指令的详细信息
这里发送内省查询:
query IntrospectionQuery{__schema{queryType{name}mutationType{name}subscriptionType{name}types{...FullType}directives{name description locations args{...InputValue}}}}fragment FullType on __Type{kind name description fields(includeDeprecated:true){name description args{...InputValue}type{...TypeRef}isDeprecated deprecationReason}inputFields{...InputValue}interfaces{...TypeRef}enumValues(includeDeprecated:true){name description isDeprecated deprecationReason}possibleTypes{...TypeRef}}fragment InputValue on __InputValue{name description type{...TypeRef}defaultValue}fragment TypeRef on __Type{kind name ofType{kind name ofType{kind name ofType{kind name ofType{kind name ofType{kind name ofType{kind name ofType{kind name}}}}}}}}
请求如下:
POST /graphql HTTP/1.1
Accept-Encoding: gzip, deflate
Connection: close
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:55.0) Gecko/20100101 Firefox/55.0
Host: xxxxxxx.com
Content-Length: 746
Content-Type: application/json
{"query": "query IntrospectionQuery{__schema{queryType{name}mutationType{name}subscriptionType{name}types{...FullType}directives{name description locations args{...InputValue}}}}fragment FullType on __Type{kind name description fields(includeDeprecated:true){name description args{...InputValue}type{...TypeRef}isDeprecated deprecationReason}inputFields{...InputValue}interfaces{...TypeRef}enumValues(includeDeprecated:true){name description isDeprecated deprecationReason}possibleTypes{...TypeRef}}fragment InputValue on __InputValue{name description type{...TypeRef}defaultValue}fragment TypeRef on __Type{kind name ofType{kind name ofType{kind name ofType{kind name ofType{kind name ofType{kind name ofType{kind name ofType{kind name}}}}}}}}"}
响应如下:
HTTP/1.1 200 OK
Server: nginx/1.14.1
Date: Thu, 22 Jun 2023 09:37:18 GMT
Content-Type: application/json
Connection: close
Cache-Control: private, must-revalidate
pragma: no-cache
expires: -1
Vary: Origin
Content-Length: 367316
{"data":{"__schema":{"queryType":{"name":"Query"},"mutationType":{"name":"Mutation"},[REDACTED]"description":"Explains why this element was deprecated, usually also including a suggestion for how to access supported similar data. Formatted using the Markdown syntax (as specified by [CommonMark](https://commonmark.org/).","type":{"kind":"SCALAR","name":"String","ofType":null},"defaultValue":""No longer supported""}]}]}}}]
也可以使用插件InQL(bp中插件)
将GraphQL接口粘贴到这里,然后点击加载。
一会将列出模式上可用的所有突变和查询。
上面两个操作可能存在脆弱点
首先测试deleteUser突变。但需要一个用户id。这里使用user查询来查找用户的id。
这里来尝试一下删除这个admin账户
没有起到作用,尝试打开一个用户帐户,并再次尝试同样的事情。
这次没有出现任何误差。来验证一下有效载荷是否有效。
再次对id -> 2运行用户查询。
admin(管理员账户)被删除了!
更新一下操作
发现起作用了,用户密码更新了。
在GraphQL中启用内省可以提供有价值的开发和调试功能,但会在生产环境中引入安全风险和潜在的资源问题。这里建议关闭该模式。
原文始发于微信公众号(迪哥讲事):GraphQL中api漏洞
免责声明:文章中涉及的程序(方法)可能带有攻击性,仅供安全研究与教学之用,读者将其信息做其他用途,由读者承担全部法律及连带责任,本站不承担任何法律及连带责任;如有问题可邮件联系(建议使用企业邮箱或有效邮箱,避免邮件被拦截,联系方式见首页),望知悉。
- 左青龙
- 微信扫一扫
-
- 右白虎
- 微信扫一扫
-
评论