# CVE-2021-44549: SMTPS server hostname not checked when making TLS connection to SMTPS server

> The library fails to verify SMTPS server identity by default, allowing man-in-the-middle attacks unless explicitly configured or upgraded.

- **Severity:** High 7.4 (`CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:H/I:H/A:N`)
- **Exploited in the wild:** Not known
- **Login needed:** Not needed
- **Attackable:** Over the internet
- **Victim action needed:** Not needed
- **Fix available:** Yes
- **Published:** 14 Dec 2021
- **Updated:** 4 Aug 2024
- **Also known as:** GHSA-c69w-jj56-834w

## What is CVE-2021-44549?

CVE-2021-44549 is a high-severity vulnerability in Apache Sling Commons Messaging Mail, published on 14 Dec 2021. An attacker can exploit it over the internet without logging in, with no action from the victim.

### Official description

Apache Sling Commons Messaging Mail provides a simple layer on top of JavaMail/Jakarta Mail for OSGi to send mails via SMTPS. To reduce the risk of "man in the middle" attacks additional server identity checks must be performed when accessing mail servers. For compatibility reasons these additional checks are disabled by default in JavaMail/Jakarta Mail. The SimpleMailService in Apache Sling Commons Messaging Mail 1.0 lacks an option to enable these checks for the shared mail session. A user could enable these checks nevertheless by accessing the session via the message created by SimpleMessageBuilder and setting the property mail.smtps.ssl.checkserveridentity to true. Apache Sling Commons Messaging Mail 2.0 adds support for enabling server identity checks and these checks are enabled by default. - https://javaee.github.io/javamail/docs/SSLNOTES.txt - https://javaee.github.io/javamail/docs/api/com/sun/mail/smtp/package-summary.html - https://github.com/eclipse-ee4j/mail/issues/429

Weakness: CWE-295 (Improper Certificate Validation)

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

2 open source packages ship an affected version, including org.apache.sling:org.apache.sling.commons.messaging.mail. It affects 1 product.


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `org.apache.sling:org.apache.sling.commons.messaging.mail` | Maven | All versions | 2.0 |
| `org.apache.sling:org.apache.sling.commons.messaging.mail` | Maven | All versions | 2.0 |

Products: Apache Sling Commons Messaging Mail.

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

Upgrade org.apache.sling:org.apache.sling.commons.messaging.mail to 2.0 or later.

## Is CVE-2021-44549 being exploited?

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

## Fix prompt for AI coding agents

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

What it is: CVE-2021-44549 is a high-severity vulnerability in Apache Sling Commons Messaging Mail, published on 14 Dec 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-44549 in the wild and no public exploit code.

Affected packages and fixed versions:
- org.apache.sling:org.apache.sling.commons.messaging.mail (Maven): affected all versions; fixed in 2.0
- org.apache.sling:org.apache.sling.commons.messaging.mail (Maven): affected all versions; fixed in 2.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-44549/ (Markdown: https://insights.sbomify.com/CVE-2021-44549/index.md)
```

## Sources

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

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