What is Apache CouchDB?
Apache CouchDB is an open-source NoSQL document database known for its RESTful HTTP API, multi-master replication, and ease of use. It is widely used for web and mobile application backends, offline-first sync scenarios, and as a backend for applications built on the CouchDB ecosystem. CouchDB uses Erlang for its runtime and clustering, inheriting Erlang's distributed computing model — including the Erlang Port Mapper Daemon (EPMD) for node discovery and inter-node communication.
Overview
CVE-2022-24706 is a critical insecure default initialization vulnerability (CWE-1188) in Apache CouchDB. In affected versions, CouchDB nodes were initialized with a predictable or known default Erlang distribution cookie — the shared secret used for Erlang node-to-node authentication in the clustering protocol. An unauthenticated attacker who can reach CouchDB's Erlang distribution port can connect using the known default cookie, joining the Erlang cluster and executing arbitrary OS-level commands with the privileges of the CouchDB process. CVSS 9.8. Fixed in CouchDB 3.2.2, which generates a cryptographically random cookie per installation.
Affected Versions
| Version | Status |
|---|---|
| Apache CouchDB prior to 3.2.2 | Vulnerable (if Erlang distribution port exposed) |
| Apache CouchDB 3.2.2 and later | Fixed (random cookie generated on install) |
Technical Details
CouchDB's clustering feature relies on Erlang's OTP distribution protocol. Erlang nodes authenticate to each other using a shared secret called the "magic cookie" stored in a .erlang.cookie file. In CouchDB installations before 3.2.2, this cookie was set to a known/default value (monster in some package configurations) rather than being randomly generated per instance.
The Erlang distribution port (default 4369 for EPMD plus the actual node port) must be reachable for exploitation. When it is:
- Attacker connects to the Erlang EPMD port (4369) to discover the CouchDB node name
- Attacker uses the known cookie value to authenticate to the Erlang distribution port
- As a peer Erlang node, the attacker has full RPC capabilities — including
os:cmd()for arbitrary OS command execution - The commands execute with the OS user privileges of the CouchDB process (typically
couchdbuser, but may be root in some deployments)
This is a well-known Erlang cluster attack pattern (similar attacks have affected RabbitMQ with default Erlang cookies).
Discovery
Identified during a security review of CouchDB's default configuration. The fix in 3.2.2 ensures a unique random cookie is generated during installation, eliminating the shared-secret predictability issue.
Exploitation Context
Erlang distribution ports (4369 and the dynamic node port range) are typically not intended to be internet-accessible, but many CouchDB deployments leave these ports reachable due to:
- Cloud security group misconfiguration (opening all ports, or "all traffic" rules)
- Docker port exposure without network filtering
- Incorrect assumption that CouchDB's HTTP API port (5984) is the only relevant port
Mass internet scanning tools like Shodan regularly index exposed CouchDB instances. Attackers exploiting this vulnerability typically install cryptominers, create backdoor OS accounts, or use the compromised database server as a pivot point.
Remediation
- Upgrade to CouchDB 3.2.2 or later: The fix generates a random Erlang cookie per installation. Existing deployments should also manually regenerate the cookie by replacing
.erlang.cookiewith a random value and restarting CouchDB. - Firewall Erlang ports: Restrict access to ports 4369 (EPMD) and the Erlang distribution port range (default 9100-9200 for CouchDB) to trusted hosts only. These ports should never be internet-accessible.
- Firewall CouchDB HTTP API: Port 5984 should also be restricted — CouchDB's HTTP API has its own authentication, but exposure without authentication is a separate risk.
- Audit for compromise: Check OS user accounts, cron jobs, and running processes for unauthorized additions. Review CouchDB database contents for unexpected records.
- Use Docker network isolation: If running CouchDB in Docker, use internal Docker networks and only expose the HTTP API port (5984) on the host, not the Erlang ports.
Key Details
| Property | Value |
|---|---|
| CVE ID | CVE-2022-24706 |
| Vendor / Product | Apache — CouchDB |
| NVD Published | 2022-04-26 |
| NVD Last Modified | 2025-10-28 |
| CVSS 3.1 Score | 9.8 |
| CVSS 3.1 Vector | CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H |
| Severity | CRITICAL |
| CWE | CWE-1188 find similar ↗ |
| CISA KEV Added | 2022-08-25 |
| CISA KEV Deadline | 2022-09-15 |
| Known Ransomware Use | No |
CVSS 3.1 Breakdown
Required Action
Timeline
| Date | Event |
|---|---|
| 2022-04-26 | CVE published; Apache CouchDB 3.2.2 released with fix |
| 2022-08-25 | Added to CISA Known Exploited Vulnerabilities catalog |
| 2022-09-15 | CISA BOD 22-01 remediation deadline |
References
| Resource | Type |
|---|---|
| NVD — CVE-2022-24706 | Vulnerability Database |
| CISA KEV Catalog Entry | US Government |
| Apache CouchDB Security Advisory — CVE-2022-24706 | Vendor Advisory |