# CVE-2022-21708: Denial of Service in graphql-go

> An attacker can cause a stack overflow panic in the graphql-go library by sending specifically designed queries, leading to a denial of service.

- **Severity:** Medium 6.5 (`CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:N/I:N/A:H`)
- **Exploited in the wild:** Not known
- **Login needed:** Any signed-in user
- **Attackable:** Over the internet
- **Victim action needed:** Not needed
- **Fix available:** Yes
- **Published:** 21 Jan 2022
- **Updated:** 23 Apr 2025
- **Also known as:** DEBIAN-CVE-2022-21708, GHSA-mh3m-8c74-74xh, GO-2022-0300, UBUNTU-CVE-2022-21708

## What is CVE-2022-21708?

CVE-2022-21708 is a medium-severity denial of service vulnerability in graph-gophers graphql-go, published on 21 Jan 2022. Any signed-in user can exploit it over the network, with no action from the victim.

### Official description

graphql-go is a GraphQL server with a focus on ease of use. In versions prior to 1.3.0 there exists a DoS vulnerability that is possible due to a bug in the library that would allow an attacker with specifically designed queries to cause stack overflow panics. Any user with access to the GraphQL handler can send these queries and cause stack overflows. This in turn could potentially compromise the ability of the server to serve data to its users. The issue has been patched in version `v1.3.0`. The only known workaround for this issue is to disable the `graphql.MaxDepth` option from your schema which is not recommended.

Weakness: CWE-674 (Uncontrolled Recursion), CWE-400 (Uncontrolled Resource Consumption)

## Which versions are affected by CVE-2022-21708?

3 open source packages ship an affected version, including github.com/graph-gophers/graphql-go. It affects 1 product.


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `github.com/graph-gophers/graphql-go` | Go | All versions | 1.3.0 |
| `github.com/graph-gophers/graphql-go` | Go | All versions | 1.3.0 |
| `github.com/graph-gophers/graphql-go` | Go | All versions | 1.3.0 |

Products: Graphql-Go Project Graphql-Go.

## How do I fix CVE-2022-21708?

Upgrade github.com/graph-gophers/graphql-go to 1.3.0 or later.

## Is CVE-2022-21708 being exploited?

There is no known exploitation of CVE-2022-21708 in the wild and no public exploit code.

## Other vulnerabilities in graph-gophers graphql-go

- [CVE-2022-37315](https://insights.sbomify.com/CVE-2022-37315/): graphql-go has infinite recursion in the type definition parser (high 7.5)

## Fix prompt for AI coding agents

```text
Check this codebase for CVE-2022-21708 and fix it if it is affected.

What it is: CVE-2022-21708 is a medium-severity denial of service vulnerability in graph-gophers graphql-go, published on 21 Jan 2022. Any signed-in user can exploit it over the network, with no action from the victim.
Exploitation: There is no known exploitation of CVE-2022-21708 in the wild and no public exploit code.

Affected packages and fixed versions:
- github.com/graph-gophers/graphql-go (Go): affected all versions; fixed in 1.3.0
- github.com/graph-gophers/graphql-go (Go): affected all versions; fixed in 1.3.0
- github.com/graph-gophers/graphql-go (Go): affected all versions; fixed in 1.3.0

Task:
1. Search the dependency manifests and lockfiles (for example package.json, package-lock.json, requirements.txt, poetry.lock, uv.lock, pom.xml, build.gradle, go.mod, Cargo.lock, Gemfile.lock) and any Dockerfiles for the affected packages, including transitive dependencies.
2. If an affected version is in use, upgrade it to the fixed version for its release line with the project's package manager, so the lockfile is regenerated. Prefer the smallest upgrade that fixes it.
3. If there is no fix, or the upgrade would break the build, do not guess: explain the risk and the safest workaround instead.
4. Run the tests and summarise what changed and why.
5. If nothing in the project is affected, say so and change nothing.

Reference: https://insights.sbomify.com/CVE-2022-21708/ (Markdown: https://insights.sbomify.com/CVE-2022-21708/index.md)
```

## Sources

- CVE record: https://www.cve.org/CVERecord?id=CVE-2022-21708
- NVD: https://nvd.nist.gov/vuln/detail/CVE-2022-21708
- OSV: https://osv.dev/vulnerability/CVE-2022-21708

---
From sbomify Insights: https://insights.sbomify.com/CVE-2022-21708/
Summaries are generated and may contain mistakes; the official description above is the record.
