# CVE-2021-22946: Protocol downgrade required TLS bypassed

curl's --ssl-reqd was silently ignored for imap/pop3 when capability commands failed and for ftp on a 230 greeting, letting a MitM strip mandatory TLS.

- Payout: hidden
- Severity: medium
- Program: curl
- Found by: monnerat
- Disclosed: 2021-09-24
- CVE: CVE-2021-22946
- Write-up quality: 7/10
- Original: https://hackerone.com/reports/1334111
- Library page: https://bugbountylibrary.com/r/h1%3A1334111
- Tags: area:devices domain:network impact:data-leak impact:integrity kind:bounty platform:hackerone sev:medium tech:curl technique:source-review vuln:crypto vuln:misconfiguration

**Target:** curl IMAP/POP3/FTP protocol handlers
**Root cause:** The TLS-required check was tied to capability negotiation success; when CAPABILITY/CAPA failed or FTP returned a non-standard 230 preauth greeting, curl proceeded in cleartext instead of aborting.
**Steps:**
1. Stand up a test server that replies `A001 BAD Not implemented` to IMAP CAPABILITY
2. Run `curl --ssl-reqd imap://server/...`; observe success with no TLS handshake on the wire
3. Configure POP3 server to reply `-ERR Not implemented` to CAPA
4. Run `curl --ssl-reqd pop3://server/...`; observe cleartext transfer
5. Configure FTP greeting to include response code 230
6. Run `curl --ssl-reqd --ftp-ssl-control ftp://server/...`; sniff to confirm TLS never negotiated
**How found:** Noticed that --ssl-reqd enforcement depended on capability command success; tested failing capability replies and a non-standard FTP 230 greeting to see if TLS was still skipped.
**Exploitation:** A network MitM intercepts the connection, causes the capability command to fail (or injects a 230 FTP greeting), and curl continues unencrypted, allowing the attacker to read and modify transferred data.
**Insight:** When a security control is gated on a negotiation step, test what happens when that step fails or returns unexpected codes — fail-open paths silently disable mandatory TLS.
