skip to content

A security review finds your internet-facing MX answers SMTP VRFY truthfully; how do you confirm the exposure, and what closes it across VRFY, EXPN and RCPT?

level: seniorimportance: should knowfreq 27%

answer

  1. replies that differ reveal the directory
  2. RFC 5321 section 7.3
  3. 252: cannot verify, will accept
  4. RCPT leaks too; slow it down

basics

~20 s

Compare your MX's VRFY replies for a real and an unknown mailbox. Close it by disabling VRFY and EXPN or limiting them to authenticated users, answering 252 as RFC 5321 7.3 requires, and rate-limiting RCPT probing.

solid answer

~50 s

The exposure is that replies differ for real and unknown mailboxes, so anyone can build a list of valid addresses for spam or phishing. Confirm it on your own MX from an outside network: compare the `VRFY` reply for a mailbox you own with the reply for one that does not exist, then read the configuration, for example Postfix's `disable_vrfy_command`, which defaults to `no`. RFC 5321 7.3 lets a site disable `VRFY` and `EXPN`, and then the server MUST return `252` rather than a code that looks like verification; it suggests offering them only to authenticated users. `RCPT TO` can reveal the same information, and rejecting unknown recipients at `RCPT` is still the usual choice, so the control there is pace: per-client recipient rate limits and error counters that slow and then drop a client, plus logs that show who probes.

code

ini · 9 lines
ini
# Postfix main.cf on the internet-facing MX
disable_vrfy_command = yes
# refuse unknown recipients at RCPT TO (the default)
smtpd_reject_unlisted_recipient = yes
# recipients per client per anvil_rate_time_unit (60s); 0 = no limit
smtpd_client_recipient_rate_limit = 1000
# slow, then disconnect, clients that keep failing (defaults)
smtpd_soft_error_limit = 10
smtpd_hard_error_limit = 20

go deeper

for a junior

Recall that VRFY, EXPN and RCPT TO can each reveal whether a mailbox exists, and that 252 is the reply for a disabled VRFY.

for a middle

Explain RFC 5321 7.3: disabling is allowed, 252 is mandatory then, 250 after a syntax check and an always-550 answer both violate it.

for a senior

Confirm the finding on your own MX, read the configuration and logs, and close RCPT probing with rate limits and error counters instead of accept-all.

for a principal

Decide whether VRFY is offered at all, and to whom, weighing internal audit value against harvesting, and own the limits that may touch large legitimate senders.

## What is exposed Three SMTP commands can tell a client whether a mailbox exists: - `VRFY <name>` asks the server to **verify** a user or mailbox; a truthful server answers `250` with the mailbox for a real one and `550` for an unknown one. - `EXPN <list>` asks the server to **expand** a mailing list, and a successful reply MUST give the mailboxes on it, one per line. - `RCPT TO:<address>` is the ordinary recipient command; a server that refuses unknown recipients with `550 5.1.1` gives the same yes-or-no answer in the course of normal mail. When the answers differ, anyone on the internet can learn which addresses are real, and RFC 5321 7.3 itself names the result: addresses harvested for spam. For a domain owner it also hands phishing campaigns a verified target list, and `EXPN` exposes list membership. ## What RFC 5321 requires 1. A site **may** disable `VRFY` and `EXPN` for security reasons (7.3). 2. If it does, the server **MUST** return `252`, rather than a code that could be confused with successful or unsuccessful verification. `252` means "Cannot VRFY user, but will accept message and attempt delivery". 3. Returning `250` after checking only the syntax violates this rule, and so does a fake `VRFY` that always answers `550`. 4. Sites that implement SMTP authentication may offer `VRFY` and `EXPN` only to authenticated requestors; the RFC still values them inside an administrative domain, for example to audit where mail is routed. Note the strength of each: `VRFY` is in RFC 5321's minimum command set, and 3.5.3 says a server answering `500` or `502` to it is not in full compliance. Disabling `VRFY` for security reasons and answering `252` is the conforming way to stop it from verifying. ## Confirming it on your own server 1. From a network outside your trusted ranges, open a session to your own MX and send `VRFY` for a mailbox you own and for an address you know does not exist. Different replies confirm the finding; identical `252` replies close it. 2. Repeat for `EXPN` against a list you run. 3. Read the configuration rather than trusting one test. In Postfix, `postconf disable_vrfy_command` shows the value; the default is `no`, and `postscreen_disable_vrfy_command` inherits it. 4. Read the logs for clients that send many `VRFY` commands, or many `RCPT TO` lines that end in unknown-user rejections, from one address. ## Closing it | Command | Control | Cost | |---|---|---| | `VRFY` | disable it, answering `252`, or allow it only after authentication | internal diagnostics lose a convenience | | `EXPN` | disable it, or allow it only after authentication | list owners lose remote inspection | | `RCPT TO` | keep refusing unknown recipients, but rate-limit and count errors | a very large legitimate sender may hit a limit | For `RCPT`, hiding the answer is usually the wrong fix. A server that accepts every recipient and sorts it out after `DATA` has to send the bounces itself later, which the material on bounces and backscatter covers. RFC 5321 7.3 adds that such a server may give no information at `RCPT`, but the price is that bounce traffic. The usual answer is to keep the honest reply and make probing slow and visible. With Postfix as the reference MTA: - `smtpd_reject_unlisted_recipient` (default `yes`) refuses unknown recipients at `RCPT TO`; - `smtpd_client_recipient_rate_limit` caps recipient addresses per client per `anvil_rate_time_unit` (60 seconds by default). Its default of `0` means no limit, and the documentation warns it is for abuse, not for regulating legitimate traffic; - `smtpd_soft_error_limit` (10) slows a client's responses by `smtpd_error_sleep_time` (1s) and `smtpd_hard_error_limit` (20) disconnects it, both counting errors made without delivering mail; - `smtpd_junk_command_limit` (100) starts counting `VRFY`, `NOOP`, `ETRN` and `RSET` as errors after that many. ## Verifying the fix - Re-run the outside test: `VRFY` should no longer distinguish a real mailbox from an unknown one. - Watch the logs after the change for clients hitting the error and rate limits. - Keep authenticated or internal access where the team relies on `VRFY` or `EXPN` for audits. - Record the decision and the test in the review, so the next audit can repeat the same check instead of rediscovering the finding. - Re-check after every MTA upgrade or configuration migration, since a rebuilt server quietly returns to the defaults.

  • Why not answer every RCPT TO with 250 so that RCPT reveals nothing?
    Because the server then accepts mail it cannot deliver and must send the bounces itself after the session, often to forged sender addresses. RFC 5321 7.3 notes that deferring recipient checks until after `DATA` can make `RCPT` uninformative, but the honest refusal at `RCPT` is the usual choice, with rate limits and error counters to slow probing.
  • Is a server that answers 502 to VRFY a compliant way of disabling it?
    Not fully. RFC 5321 3.5.3 says implementations that return `500` or `502` for `VRFY` are not in full compliance, and 7.3 says a site that disables `VRFY` for security reasons MUST return `252`. Check what your MTA actually sends when the command is disabled.
  • When is keeping VRFY or EXPN worth it?
    Inside an administrative domain or for authenticated users. RFC 5321 7.3 gives internal audits as the example, checking how mail is routed and that no one forwards sensitive mail outside, and suggests offering the commands only to authenticated requestors.

  • Disabling VRFY means answering 550 to every VRFY request.
  • Once VRFY and EXPN are off, addresses can no longer be probed.
  • Accepting all recipients at RCPT and bouncing later is the clean fix.
  • RFC 5321 forbids implementing VRFY at all.
  • A 250 after a syntax check is a safe way to answer VRFY.