# CVE-2021-21404: Crash due to malformed relay protocol message

> An attacker can crash the Syncthing relay server or client by sending a malformed message with a negative length field, causing a denial of service.

- **Severity:** High 7.5 (`CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H`)
- **Exploited in the wild:** Not known
- **Login needed:** Not needed
- **Attackable:** Over the internet
- **Victim action needed:** Not needed
- **Fix available:** Yes
- **Published:** 6 Apr 2021
- **Updated:** 3 Aug 2024
- **Also known as:** BIT-syncthing-2021-21404, DEBIAN-CVE-2021-21404, GHSA-x462-89pf-6r5h, GO-2022-0888, UBUNTU-CVE-2021-21404, openSUSE-SU-2021:0688-1, openSUSE-SU-2021:0713-1, openSUSE-SU-2024:11417-1

## What is CVE-2021-21404?

CVE-2021-21404 is a high-severity denial of service vulnerability in syncthing, published on 6 Apr 2021. An attacker can exploit it over the internet without logging in, with no action from the victim.

### Official description

Syncthing is a continuous file synchronization program. In Syncthing before version 1.15.0, the relay server `strelaysrv` can be caused to crash and exit by sending a relay message with a negative length field. Similarly, Syncthing itself can crash for the same reason if given a malformed message from a malicious relay server when attempting to join the relay. Relay joins are essentially random (from a subset of low latency relays) and Syncthing will by default restart when crashing, at which point it's likely to pick another non-malicious relay. This flaw is fixed in version 1.15.0.

Weakness: CWE-20 (Improper Input Validation)

## Which versions are affected by CVE-2021-21404?

4 open source packages ship an affected version, including github.com/syncthing/syncthing and syncthing. It affects 1 product.


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `github.com/syncthing/syncthing` | Go | All versions | 1.15.0 |
| `github.com/syncthing/syncthing` | Go | All versions | 1.15.0 |
| `github.com/syncthing/syncthing` | Go | All versions | 1.15.0 |
| `syncthing` | Bitnami | All versions | 1.15.0 |
| `syncthing` | SUSE:Package Hub 15 SP2 | All versions | 1.15.1-bp152.2.3.1 |
| `syncthing` | openSUSE:Leap 15.2 | All versions | 1.15.1-lp152.2.3.1 |
| `syncthing` | openSUSE:Tumbleweed | All versions | 1.18.2-2.1 |

Products: Syncthing Syncthing.

## How do I fix CVE-2021-21404?

Upgrade github.com/syncthing/syncthing to 1.15.0 or later.

## Is CVE-2021-21404 being exploited?

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

## Other vulnerabilities in syncthing

- [CVE-2017-1000420](https://insights.sbomify.com/CVE-2017-1000420/): Syncthing vulnerable to symlink traversal and arbitrary file overwrite (high 7.5)
- [CVE-2022-46165](https://insights.sbomify.com/CVE-2022-46165/): Cross-site Scripting (XSS) in Web GUI in syncthing (medium 4.6)

## Fix prompt for AI coding agents

```text
Check this codebase for CVE-2021-21404 and fix it if it is affected.

What it is: CVE-2021-21404 is a high-severity denial of service vulnerability in syncthing, published on 6 Apr 2021. An attacker can exploit it over the internet without logging in, with no action from the victim.
Exploitation: There is no known exploitation of CVE-2021-21404 in the wild and no public exploit code.

Affected packages and fixed versions:
- github.com/syncthing/syncthing (Go): affected all versions; fixed in 1.15.0
- github.com/syncthing/syncthing (Go): affected all versions; fixed in 1.15.0
- github.com/syncthing/syncthing (Go): affected all versions; fixed in 1.15.0
- syncthing (Bitnami): affected all versions; fixed in 1.15.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-2021-21404/ (Markdown: https://insights.sbomify.com/CVE-2021-21404/index.md)
```

## Sources

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

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