In explicit FTPS (RFC 4217), what do AUTH TLS, PBSZ 0 and PROT P each do, and how does implicit FTPS on port 990 differ?
answer
- upgrade on the same port
- 234, then a TLS handshake
- buffer size zero because TLS streams
- data starts Clear
- 990 is convention, not RFC
basics
~20 sExplicit FTPS starts as plain FTP on port 21: AUTH TLS (reply 234) encrypts the control connection, PBSZ 0 is the required preamble, PROT P encrypts data connections. Implicit FTPS starts TLS at connect, conventionally on 990, outside any RFC.
solid answer
~50 sIn **explicit FTPS** the client connects to port 21 in clear text and sends `AUTH TLS`; the server answers `234 Security data exchange complete.` and a TLS handshake runs on the same connection. RFC 4217 requires `USER` to be issued after `AUTH`, even by a client that logged in before, and resets transfer parameters, so the login happens inside TLS. `PBSZ 0` sets the protection buffer size: RFC 2228 demands a `PBSZ` before any `PROT`, and because TLS is a stream the value is 0. `PROT P` (Private) makes every later data connection run its own TLS handshake before bytes move; `PROT C` (Clear) is the starting state. **Implicit FTPS** skips `AUTH`: the client begins TLS as soon as TCP connects, by convention on port 990. RFC 4217 defines only the explicit form, so implicit is a widely supported convention, not a standard.
go deeper
Remember the sequence AUTH TLS, PBSZ 0, PROT P on port 21, and that implicit FTPS starts TLS at connect on port 990.
Explain why data starts Clear, why PBSZ must precede PROT with the value 0, and that RFC 4217 defines only explicit FTPS.
Show how to make explicit FTPS non-optional: TLS required before login, PROT P required for data, and clients that refuse to continue when AUTH is rejected.
Weigh offering one explicit endpoint on 21 against an extra implicit listener on 990 for clients that cannot upgrade, given the downgrade and support costs of each.
## The explicit FTPS exchange **Explicit FTPS** is FTP that upgrades itself to TLS on request, as profiled by RFC 4217 on top of the FTP security extensions of RFC 2228. A typical session (C: client, S: server): 1. C connects to TCP 21; S: `220` greeting, in clear text. 2. C: `AUTH TLS` - S: `234 Security data exchange complete.` 3. Both sides run a TLS handshake on the same TCP connection; from here the control connection is encrypted. 4. C: `USER deploy` - S: `331 User name okay, need password.`; C: `PASS ...` - S: `230 User logged in, proceed.` 5. C: `PBSZ 0` - S: `200 Command okay.` 6. C: `PROT P` - S: `200 Command okay.` 7. The client sets up a data connection, sends `STOR`, the server replies `150`, and a second TLS handshake runs on the data connection before the file moves; `226` follows when it closes. RFC 4217 lets the server dictate the order: some want `PBSZ`/`PROT` before login, some after. Clients are told not to hard-wire the sequence. ## What each command does | Command | Reply when accepted | Effect | |---|---|---| | `AUTH TLS` | `234` | Start TLS on the control connection. `334` would mean an ADAT exchange follows, which TLS does not use. | | `PBSZ 0` | `200` | Protection buffer size. RFC 2228 requires it before `PROT`; TLS is a stream, so no buffering: 0. | | `PROT P` | `200` | Data connections are Private: TLS on each one. | | `PROT C` | `200` | Data connections are Clear: no TLS. This is the initial state. | Two RFC 4217 details matter in practice: - After `AUTH`, the client **must issue `USER`** (again, if it had already logged in), and the server resets the user identity, `TYPE`, `MODE`, the default data port and the working directory, almost as if the session restarted. Anything set before `AUTH` does not carry over. - A server that supports `FEAT` must list `AUTH TLS`, `PBSZ` and `PROT` in its reply, which is how a client discovers FTPS support. ## Data connections: Clear until PROT P RFC 4217 states that the initial data connection state **must be Clear**. Encrypting the control connection does not encrypt files. Once `PROT P` is set: - each data connection, opened for each transfer or listing, performs its own TLS handshake before any bytes cross; - the server checks the protection level on the command that opens the data connection (`STOR`, `RETR`, `LIST`, `NLST`, `STOU`, `APPE`) and can refuse it if the `PROT` setting is not acceptable; - RFC 4217 allows a server to insist that a data connection **resumes the TLS session** of the control connection or a previous data connection, which proves the data connection comes from the client that logged in. ## Implicit FTPS: the convention on 990 **Implicit FTPS** assumes TLS from the first byte. The client connects, the TLS handshake starts immediately, and FTP's `220` greeting arrives inside TLS. There is no `AUTH` command. By long-standing convention it listens on **port 990**, separate from plain FTP on 21. RFC 4217 does not describe this mode at all: it defines session negotiation on the normal control port only. Implicit FTPS is therefore a **never-standardised convention** that many servers and clients still support, often on a separate listener from the explicit one. ## Explicit and implicit side by side | | Explicit FTPS | Implicit FTPS | |---|---|---| | Standard | RFC 4217 | none; a convention | | Port | 21, shared with plain FTP | conventionally 990 | | Start of session | clear `220`, then `AUTH TLS` | TLS handshake at connect | | Can one port serve TLS and non-TLS clients | yes | no | | Downgrade risk | if the client accepts an `AUTH` refusal | none at the start; TLS or nothing | | Data protection | needs `PBSZ 0` + `PROT P` | set by server policy; clients usually still send `PBSZ 0` + `PROT P` | ## Traps - **Optional TLS.** RFC 4217 lets a client continue in clear text after an `AUTH` refusal. A client set to "use TLS if available" can be talked down by anyone who can tamper with the first, unencrypted exchange; clients that must protect credentials should require TLS. - **Login before AUTH.** If the client sends `USER` and `PASS` before `AUTH TLS`, the password has already crossed in clear. Servers can refuse login commands until TLS is up. - **Forgetting PROT P.** A session can show a padlock on the control connection while every file crosses in clear.
- How does an FTPS server signal that a transfer cannot proceed because of the data protection setting?RFC 4217 has the server check the protection level on the command that opens the data connection, not on `PASV` or `PORT`. Section 10.2 gives `521` ('data connection cannot be opened with this PROT setting'); another passage uses `522` for the same refusal, and `522` also reports a TLS negotiation on the data connection that failed or was unacceptable, sent after the `150`.
- Why might an FTPS server require each data connection to resume the control connection's TLS session?RFC 4217 allows a server to insist on a cached TLS session for data connections. Resuming proves the data connection comes from the same client that negotiated the control connection, rather than from someone who connected to the data port first, and it saves a full handshake per transfer. Some clients do not resume sessions and fail against servers that enforce it.
- If an FTP server rejects AUTH TLS, what should an FTPS client that must protect credentials do?Disconnect before sending `USER` or `PASS`. RFC 4217 permits a client to carry on unprotected after a rejection, which is exactly what an on-path attacker exploits by forging the refusal in the clear-text opening. A client configured to require TLS fails closed instead of downgrading.
- Implicit FTPS on port 990 is the mode RFC 4217 standardises
- AUTH TLS by itself also encrypts the data connections
- PBSZ sets the TLS record size, so larger values are faster
- Explicit FTPS needs a second listening port beside 21
- Settings made before AUTH TLS carry over into the protected session