# GHSA-gwj5-3vfq-q992: Import loops in account imports, nats-server DoS

> An attacker with an account can crash the NATS server by creating import loops, causing resource exhaustion and denial of service.

- **Severity:** Not scored
- **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 May 2021
- **Also known as:** GO-2022-0398

## What is GHSA-gwj5-3vfq-q992?

GHSA-gwj5-3vfq-q992 is a denial of service vulnerability in github.com/nats-io/nats-server, published on 21 May 2021. Any signed-in user can exploit it over the network, with no action from the victim.

### Official description

(This advisory is canonically <https://advisories.nats.io/CVE/CVE-2020-28466.txt>)

## Problem Description

An export/import cycle between accounts could crash the nats-server, after consuming CPU and memory.

This issue was fixed publicly in <https://github.com/nats-io/nats-server/pull/1731> in November 2020.

The need to call this out as a security issue was highlighted by `snyk.io` and we are grateful for their assistance in doing so.

Organizations which run a NATS service providing access to accounts run by untrusted third parties are affected.
See below for an important caveat if running such a service.

## Affected versions

#### NATS Server

 * Version 2 prior to 2.2.0
   + 2.0.0 through and including 2.1.9 are vulnerable.
 * fixed with nats-io/nats-server PR 1731, commit 2e3c226729

## Impact

The nats-server could be killed, after consuming resources.

## Workaround

The import cycle requires at least two accounts to work; if you have open account sign-up, then restricting new account sign-up might hinder an attacker.

## Solution

Upgrade the nats-server.

## Caveat on NATS with untrusted users

Running a NATS service which is exposed to untrusted users presents a heightened risk.

Any remote execution flaw or equivalent seriousness, or denial-of-service by unauthenticated users, will lead to prompt releases by the NATS maintainers.

Fixes for denial of service issues with no threat of remote execution, when limited to account holders, are likely to just be committed to the main development branch with no special attention.

Those who are running such services are encouraged to build regularly from git.

## Which versions are affected by GHSA-gwj5-3vfq-q992?

4 open source packages ship an affected version, including github.com/nats-io/nats-server/v2 and github.com/nats-io/nats-server.


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `github.com/nats-io/nats-server/v2` | Go | All versions | 2.2.0 |
| `github.com/nats-io/nats-server/v2` | Go | All versions | 2.2.0 |
| `github.com/nats-io/nats-server/v2` | Go | All versions | 2.2.0 |
| `github.com/nats-io/nats-server` | Go | All versions | None |

## How do I fix GHSA-gwj5-3vfq-q992?

Upgrade github.com/nats-io/nats-server/v2 to 2.2.0 or later.

## Is GHSA-gwj5-3vfq-q992 being exploited?

There is no known exploitation of GHSA-gwj5-3vfq-q992 in the wild and no public exploit code.

## Fix prompt for AI coding agents

```text
Check this codebase for GHSA-gwj5-3vfq-q992 and fix it if it is affected.

What it is: GHSA-gwj5-3vfq-q992 is a denial of service vulnerability in github.com/nats-io/nats-server, published on 21 May 2021. Any signed-in user can exploit it over the network, with no action from the victim.
Exploitation: There is no known exploitation of GHSA-gwj5-3vfq-q992 in the wild and no public exploit code.

Affected packages and fixed versions:
- github.com/nats-io/nats-server/v2 (Go): affected all versions; fixed in 2.2.0
- github.com/nats-io/nats-server/v2 (Go): affected all versions; fixed in 2.2.0
- github.com/nats-io/nats-server/v2 (Go): affected all versions; fixed in 2.2.0
- github.com/nats-io/nats-server (Go): affected all versions; no fix listed

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/GHSA-gwj5-3vfq-q992/ (Markdown: https://insights.sbomify.com/GHSA-gwj5-3vfq-q992/index.md)
```

## Sources

- OSV: https://osv.dev/vulnerability/GHSA-gwj5-3vfq-q992

---
From sbomify Insights: https://insights.sbomify.com/GHSA-gwj5-3vfq-q992/
Summaries are generated and may contain mistakes; the official description above is the record.
