# CVE-2021-32749: Possible RCE vulnerability in mailing action using mailutils (mail-whois)

> Attackers can execute arbitrary commands via malicious whois responses in fail2ban's mail-whois action, requiring specific configuration.

- **Severity:** Medium 6.1 (`CVSS:3.1/AV:N/AC:H/PR:N/UI:R/S:C/C:N/I:H/A:N`)
- **Exploited in the wild:** Not known
- **Login needed:** Not needed
- **Attackable:** Over the internet
- **Victim action needed:** A user has to click or open something
- **Fix available:** Yes
- **Published:** 16 Jul 2021
- **Updated:** 3 Aug 2024
- **Also known as:** ALPINE-CVE-2021-32749, DEBIAN-CVE-2021-32749, GHSA-m985-3f3v-cwmm, MGASA-2021-0464, UBUNTU-CVE-2021-32749, USN-5232-1, openSUSE-SU-2021:1274-1, openSUSE-SU-2024:10749-1

## What is CVE-2021-32749?

CVE-2021-32749 is a medium-severity command injection vulnerability in Fedoraproject Fedora, published on 16 Jul 2021. An attacker can exploit it over the internet without logging in, and only if a user opens a file or follows a link.

### Official description

fail2ban is a daemon to ban hosts that cause multiple authentication errors. In versions 0.9.7 and prior, 0.10.0 through 0.10.6, and 0.11.0 through 0.11.2, there is a vulnerability that leads to possible remote code execution in the mailing action mail-whois. Command `mail` from mailutils package used in mail actions like `mail-whois` can execute command if unescaped sequences (`\n~`) are available in "foreign" input (for instance in whois output). To exploit the vulnerability, an attacker would need to insert malicious characters into the response sent by the whois server, either via a MITM attack or by taking over a whois server. The issue is patched in versions 0.10.7 and 0.11.3. As a workaround, one may avoid the usage of action `mail-whois` or patch the vulnerability manually.

Weakness: CWE-94 (Improper Control of Generation of Code), CWE-78 (Improper Neutralization of Special Elements used in an OS Command)

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

It affects 2 products.


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `fail2ban` | SUSE:Package Hub 15 SP1 | All versions | 0.11.2-bp153.2.3.1 |
| `fail2ban` | SUSE:Package Hub 15 SP2 | All versions | 0.11.2-bp153.2.3.1 |
| `fail2ban` | SUSE:Package Hub 15 SP3 | All versions | 0.11.2-bp153.2.3.1 |
| `fail2ban` | openSUSE:Leap 15.2 | All versions | 0.11.2-bp153.2.3.1 |
| `fail2ban` | openSUSE:Leap 15.3 | All versions | 0.11.2-bp153.2.3.1 |
| `fail2ban` | openSUSE:Tumbleweed | All versions | 0.11.2-3.1 |

Products: Fail2ban Fail2ban, Fedoraproject Fedora.

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

Upgrade to a fixed version.

## Is CVE-2021-32749 being exploited?

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

## Other vulnerabilities in Fedoraproject Fedora

- [CVE-2012-5642](https://insights.sbomify.com/CVE-2012-5642/): Command injection in n/a (high 7.5)
- [CVE-2007-4321](https://insights.sbomify.com/CVE-2007-4321/): Denial of service in n/a (medium 6.8)
- [CVE-2013-7176](https://insights.sbomify.com/CVE-2013-7176/): Denial of service in n/a (medium 5.0)
- [CVE-2013-7177](https://insights.sbomify.com/CVE-2013-7177/): Denial of service in n/a (medium 5.0)
- [CVE-2013-2178](https://insights.sbomify.com/CVE-2013-2178/): Denial of service in n/a (medium 5.0)

## Fix prompt for AI coding agents

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

What it is: CVE-2021-32749 is a medium-severity command injection vulnerability in Fedoraproject Fedora, published on 16 Jul 2021. An attacker can exploit it over the internet without logging in, and only if a user opens a file or follows a link.
Exploitation: There is no known exploitation of CVE-2021-32749 in the wild and no public exploit code.

Affected product: Fedoraproject Fedora. No package-level version data is available, so check the vendor advisory linked from the reference page.

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-32749/ (Markdown: https://insights.sbomify.com/CVE-2021-32749/index.md)
```

## Sources

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

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