
GraphQL API के स्वचालित सुरक्षा ऑडिटिंग के लिए हल्का पायथन उपकरण। गलत कॉन्फ़िगरेशन, सूचना लीक, और सेवा-अस्वीकृति भेद्यताओं का cURL पुनरुत्पादन कमांड के साथ पता लगाता है।
GraphQL Cop एक छोटी Python उपयोगिता है जो GraphQL API के विरुद्ध सामान्य सुरक्षा परीक्षण चलाने के लिए है। GraphQL Cop GraphQL में CI/CD जाँच चलाने के लिए उपयुक्त है। यह हल्का है और GraphQL में रोचक सुरक्षा मुद्दों को कवर करता है।
GraphQL Cop किसी भी पहचानी गई कमजोरियों पर cURL कमांड प्रदान करके निष्कर्षों को पुन: उत्पन्न करने की अनुमति देता है।
निर्भरताओं को स्थापित करने के लिए नीचे दिए गए कमांड निष्पादित किए जाने चाहिए।
python3 -m venv path/to/venv
source path/to/venv/bin/activate
python3 -m pip install -r requirements.txt
पहला कमांड path/to/venv द्वारा निर्दिष्ट निर्देशिका में एक वर्चुअल वातावरण बनाता है।
दूसरा कमांड वर्चुअल वातावरण को सक्रिय करता है।
अंतिम कमांड requirements.txt में सूचीबद्ध सभी Python पैकेजों को स्थापित करता है।
$ python3 graphql-cop.py -h
Usage: graphql-cop.py -t http://example.com -o json
Options:
-h, --help show this help message and exit
-t URL, --target=URL target url with the path - if a GraphQL path is not
provided, GraphQL Cop will iterate through a series of
common GraphQL paths
-H HEADER, --header=HEADER
Append Header(s) to the request '{"Authorization":
"Bearer eyjt"}' - Use multiple -H for additional
Headers
-o FORMAT, --output=FORMAT
json
-e EXCLUDED_TESTS, --excluded-tests=EXCLUDED_TESTS
Exclude specific tests
-l, --list-tests List available tests
-f, --force Forces a scan when GraphQL cannot be detected
-d, --debug Append a header with the test name for debugging
-x PROXY, --proxy=PROXY
HTTP(S) proxy URL in the form
http://user:pass@host:port
-w WORDLIST, --wordlist=WORDLIST
Path to a list of custom GraphQL endpoints
-v, --version Print out the current version and exit.
-T, --tor Sends the request through the Tor network (ensure Tor
is running and properly configured)
$ python3 graphql-cop.py -t https://mywebsite.com/graphql
[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)
$ python3 graphql-cop.py -t https://mywebsite.com/graphql -e field_duplication
[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)
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'}]
$ python3 graphql-cop.py -t https://mywebsite.com/graphql --proxy=http://127.0.0.1:8080 --header '{"Authorization": "Bearer token_here"}'
[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)
git clone https://github.com/dolevf/graphql-cop.git
cd graphql-cop
docker build -t graphql-cop:latest .
आप डॉकर कंटेनर चला सकते हैं और graphql-cop स्क्रिप्ट में तर्क इस प्रकार पास कर सकते हैं:
docker run --rm -it graphql-cop:latest -t <GRAPHQL_ENDPOINT> -H '{"<HEADER_KEY>": "<HEADER_VALUE>"}'
यहाँ कंटेनर चलाने का एक उदाहरण है:
docker run --rm -it graphql-cop:latest -t https://example.com/graphql -H '{"Authorization": "Bearer abc123xyz"}'
सभी उपलब्ध विकल्पों की सूची के लिए, चलाएँ:
docker run --rm -it graphql-cop:latest --help
समस्या निवारण