Why do passive FTP transfers through a firewall's FTP helper stop working the day a customer switches to explicit FTPS, and what options remain?
answer
- the helper was doing hidden work
- ciphertext on port 21
- static range instead of inspection
- clear the command channel
basics
~20 sAn FTP helper reads 227 replies on port 21 to rewrite the address and open a pinhole; after AUTH TLS it sees only ciphertext. Advertise the public address and statically open a fixed passive range, or send CCC after login.
solid answer
~50 sBefore FTPS, a NAT or stateful firewall FTP helper parsed each `227 Entering Passive Mode` reply on port 21, opened a pinhole for the announced port and often silently rewrote a private address into the public one. Explicit FTPS starts with `AUTH TLS`, answered `234`, and from then on the control connection is TLS records. The helper can read neither the address nor the port, so passive data connections hit a closed firewall or a private address; some helpers even cut the connection when the TLS handshake starts. The robust fix is to stop depending on inspection: configure the server's advertised public address and a fixed passive range, and forward and open that range statically. The other option RFC 4217 describes is `CCC` after login, which drops the control connection back to clear text so the helper can read it again, at the cost of protecting the commands that follow; servers may refuse it.
go deeper
Recall that firewalls handle FTP by reading the control connection on port 21, and that FTPS encrypts that connection after AUTH TLS.
Explain the two jobs a helper does, rewriting the address and opening a pinhole, and why both fail once the control connection is encrypted.
Recommend a server-advertised public address with a statically opened passive range, explain CCC's replies and limits, and spot a helper that kills the TLS handshake.
Judge whether to keep FTPS with standing open ranges, accept CCC's clear-text commands for compatibility, or move partners to a single-port protocol.
## What the helper was quietly doing A **stateful firewall** or **NAT** device usually ships an FTP **helper**, or application-level gateway (ALG). On every FTP control connection it watches for the messages that announce a data connection, `PORT`, `EPRT`, `227 Entering Passive Mode` and `229 Entering Extended Passive Mode`, and then: - opens a short-lived pinhole for exactly that data connection; - where the device also translates addresses, rewrites the private address written in `PORT` or `227` into the public one, and fixes up the TCP stream to match. In the hosting scenario, the provider's server sat on a private address and nobody had configured it to advertise its public one. Passive mode worked only because the helper was rewriting every `227` and opening every pinhole. ## What FTPS changes Explicit FTPS (RFC 4217) upgrades the existing control connection on port 21: 1. C: `AUTH TLS` 2. S: `234` (security data exchange complete), then the TLS handshake 3. C: `PBSZ 0`, then `PROT P` to protect the data connections too 4. C: `USER` and `PASS`, now inside TLS 5. C: `PASV`, and the `227` reply comes back encrypted From step 2 onward the helper sees only TLS records. RFC 3027, which catalogues protocols that break under NAT, says so directly: if the control channel is secured, an ALG cannot update the addresses in it. The result: - the private address in `227` reaches the client unrewritten; - no pinhole opens, so even a correct address meets a closed port; - some helpers react to the unexpected handshake by terminating the control connection, which a server logs as an unexpected end of file during TLS negotiation. `EPSV` removes the address problem, since `229` carries only a port, but not the pinhole problem: the port is still hidden from the helper. ## The options left | Option | What it does | What it costs | |---|---|---| | Static range | Server advertises its public address and uses a fixed passive range; NAT forwards and firewall allows it permanently | A standing open range; no dependence on inspection | | `CCC` after login | Control connection returns to clear text after authentication, so the helper can read `227` again | Commands and replies after `CCC` are unprotected; servers may refuse | | Leave FTP | Move the partner to a single-port protocol | A migration, decided on security and partner grounds | **The static range** is the option that works through any firewall, which is why ProFTPD's TLS notes point at it: a firewall that always allows the passive range needs no visibility into the session. With vsftpd that is `pasv_address`, `pasv_min_port` and `pasv_max_port`; with ProFTPD, `MasqueradeAddress` and `PassivePorts`. A helper that kills TLS connections has to be disabled for that traffic either way. **`CCC`** (Clear Command Channel) is defined in RFC 2228 and profiled by RFC 4217 for exactly this case. The typical sequence protects `AUTH`, `USER`, `PASS`, `PBSZ` and `PROT`, then sends `CCC`. The server's answers: - `200`: TLS on the control connection is shut down, the socket stays open, and the next command arrives in clear text; - `533`: the control connection was not protected in the first place; - `534`: the server is not willing to clear it; - `500`: the server does not understand `CCC`. After a `200`, `PBSZ` and `PROT` are no longer accepted and data connections keep the protection already chosen, so files stay encrypted under `PROT P`. CCC only helps if the helper is still parsing that connection after it saw TLS start. Servers are free to refuse it, and RFC 4217 notes that they may refuse it before the client has authenticated; ProFTPD, for example, accepts CCC only under `TLSRequired auth+data`. **Implicit FTPS on 990**, a never-standardised convention, does not help: TLS starts with the first byte, so the helper is blind from the start. ## What to say in the interview The insight is that encryption did not break FTP; it exposed a dependency on inspection that was already there. A senior answer names the hidden rewrite, explains why both the address and the pinhole fail, recommends making the server self-sufficient with a public address and a statically opened range, and treats `CCC` as a compatibility tool to use deliberately, not by default.
- After a 200 reply to CCC, are the files still encrypted?Yes, if `PROT P` was set before `CCC`. RFC 4217 says the server stops accepting `PBSZ` and `PROT` after clearing, and later data transfers keep the protection level already in force. Only the control connection returns to clear text, which is exactly what lets the helper read `227` again.
- The FTPS server logs an end-of-file error during the TLS handshake on the control connection. What is the likely cause?An FTP-aware NAT or firewall between client and server. It inspects port 21, sees a TLS handshake where it expected FTP commands, and terminates the connection. Disable the helper for that path and rely on a statically opened passive range; no server setting fixes a device that kills the connection.
- FTPS broke because TLS needs its own port, so open 990 and passive works
- The firewall helper reads data connections, so PROT C would fix it
- CCC turns encryption off for the files as well as the commands
- EPSV fixes FTPS through a helper because the helper no longer needs the port
- Servers must accept CCC because RFC 4217 defines it