Contents · Forum Home · StreamSec Tools 4.1.5.363 documentation

SFTP implementation notes

================================================================================
 SFTP SUBSYSTEM IMPLEMENTATION
 Analysis of the StreamSec.SFTP.* units (SSH File Transfer Protocol, v3 + v5)
 (StreamSec Security Library for Embarcadero Delphi)
================================================================================

Generated: 2026-07-20

Companion to SSH.txt (the SSH-2.0 transport/auth/connection layer this rides on).
SFTP is a SUBSYSTEM of the SSH connection protocol: everything here is framed on
a "session" channel opened with the "subsystem" request, name "sftp". Read
SSH.txt sections 7 (channel close/EOF) and 8 (subsystem authorization contract)
first - both bear directly on how this subsystem must behave.


--------------------------------------------------------------------------------
0. SUMMARY
--------------------------------------------------------------------------------

Six units in the StrSecIV370 runtime package, plus design-time registration in
DStrSecIV370. Protocol versions 3 and 5, CLIENT and SERVER.

  CLIENT  TstSFTPClient - a full file-transfer client (get/put/list/mkdir/
          rename/delete/resume/compare). It supersedes the incomplete stSFTP*
          units of StreamSec Tools 3.
  SERVER  TstSFTPServerSubSystem - a JAILED, SINGLE-IDENTITY server subsystem.

Interop, both directions (section 7):
  * as a SERVER - OpenSSH `sftp`, PuTTY `psftp`, curl/libssh2, WinSCP and
    paramiko each complete a mkdir/put/ls/get/rm/rmdir round trip against us.
    All five negotiate v3, so our v5 server encoder is exercised only by our own
    client.
  * as a CLIENT - we drive the real OpenSSH `sftp-server.exe` through a private
    sshd, which is also the only coverage of our v3 client path.
  * an internal client<->server self-test passes.

WHAT THIS IS NOT: it is not a general-purpose multi-user file server. There is no
user impersonation - see section 5 for why that is a deliberate design decision
and what it costs.


================================================================================
1. UNIT INVENTORY
================================================================================

  StreamSec.SFTP.Types.pas           Protocol constants (SSH_FXP_*, SSH_FX_*,
                                     SSH_FXF_*) and the iFileAttributes
                                     interface shared by both versions.
  StreamSec.SFTP.Version3Types.pas   Protocol-3 attribute encode/decode.
  StreamSec.SFTP.Version5Types.pas   Protocol-5 attributes, ACLs, and the
                                     tSupportedStructure the server advertises.
  StreamSec.SFTP.Transport.pas       The SFTP packet layer: request/response
                                     correlation, request IDs, packet framing on
                                     an SSH channel. iSFTPClientTransport.
  StreamSec.SFTP.Client.pas          TstSFTPClient component (the API in
                                     section 3).
  StreamSec.SFTP.ServerSubSystem.pas The server: tSFTPServerSubSystem (per
                                     channel), TstSFTPServerSubSystem (the
                                     component), tSFTPJail, plus a self-contained
                                     tSFTPWriter/tSFTPReader/tSFTPAttrs.
                                     tSFTPJail is an adapter over stFileJail -
                                     see FileJail.txt and section 5.
  StreamSec.SFTP.Reg.pas / .dcr      Design-time registration (DStrSecIV370
                                     only): TstSFTPClient +
                                     TstSFTPServerSubSystem on the 'StreamSec SSH
                                     Tools' palette page, icons at 16/24/32,
                                     32-bpp BGRA.

Dependency direction: Types <- Version3/5Types <- Transport <- Client, with
ServerSubSystem depending on the SSH server/channel units rather than on
Transport (it speaks the wire format directly - see section 4).


================================================================================
2. SPECIFICATION STATUS - WHAT "SFTP v3 / v5" ACTUALLY MEANS
================================================================================

There is NO RFC for SFTP. The protocol was developed in the IETF secsh working
group and every version document EXPIRED as an Internet-Draft:

  draft-ietf-secsh-filexfer-02   protocol version 3   IMPLEMENTED, tested
  draft-ietf-secsh-filexfer-04   protocol version 4   NOT implemented (see below)
  draft-ietf-secsh-filexfer-05   protocol version 5   IMPLEMENTED, tested
  draft-ietf-secsh-filexfer-13   protocol version 6   NOT implemented

Only versions 3 and 5 are supported. Version 3 is the de-facto standard: it is
what OpenSSH implements and therefore what the overwhelming majority of deployed
clients negotiate. Version 5 adds ACLs, richer/typed attributes, and explicit
SSH_FXP_RENAME flags. Versions 4 and 6 are thinly deployed; supporting 3 and 5
covers essentially the whole installed base.

VERSION NEGOTIATION (server, tSFTPServerSubSystem.DoInit):
  cSFTPServerMaxVersion = 5.
    client >= 5  -> 5
    client <  5  -> 3   (so a v4 or v3 client both get v3)

WHY V4 IS NOT SERVED AS 4. The encode/decode sites split only TWO ways -
`if fVersion <= 3` for the v3 shape and `if fVersion >= 5` for the v5 shape -
with no v4 branch. That split is fine for 3 and 5 but WRONG for 4, because v4 is
not merely "v5 minus the ACL/bits extras" on the wire:
  * SSH_FXP_OPEN in v4 carries `pflags` (a bitmask, as in v3), whereas v5
    replaced it with `desired-access` + `flags`. The server reads pflags only
    for fVersion <= 3, so an as-v4 OPEN would be misparsed as v5.
  * SSH_FXP_RENAME gained its flags word in v5; v4 has none. The server reads
    that word for fVersion > 3, which a real v4 client never sends.
So serving a peer AS v4 would speak v5 wire and break a genuine v4 client.
Rather than half-implement v4, DoInit negotiates any client below 5 DOWN to 3
(responding with a lower version than the client offered is standard SFTP
negotiation, and every v4 client can also speak v3). This is a change from
release 4.1.1.354, which agreed on 4 and then served the v5 wire described
above; the copy of this document shipped with it wrongly called v4 "served
properly". Both the negotiation and the description are corrected here.


================================================================================
3. CLIENT  (TstSFTPClient)
================================================================================

  Connect / ConnectNew          -> iSFTPClientTransport (opens the subsystem
                                   channel and performs INIT/VERSION).
  ChangeCurrentDir / RetrieveCurrentDir
  List(dir)                     -> iFileAttributesList
  GetFile(remote, local | stream, canOverwrite, resume)
  PutFile(source | stream, dest, append)
  CmpFile(source | stream, dest, offset, length)   byte-range compare
  Size(name)                    -> Int64
  MakeDir / RemoveDir / Rename(flags) / Delete
  ServerSupported               -> tSupportedStructure (v5 only)

  Published: Transport, OnGetTransport, OnReadDir.

  PORTING NOTES (things that were wrong or non-obvious in the stSFTP* original):
  - PATHS ARE UTF-8 BYTES, not native strings. The draft specifies UTF-8 on the
    wire; the original round-tripped through the ANSI/Unicode string type and
    corrupted non-ASCII names. Ported to tBytes via a ToUtf8Bytes helper, with
    EncodeBytes/DecodeUtf8Str replacing EncodeStr/Utf8ToUnicode(DecodeStr(...)).
  - SSH_FXP_READ encoded an empty path variable instead of the file HANDLE -
    reads could not have worked.
  - ReadDir was missing a Dec(lCount) and would over-read its result set.
  - DecodeStatus read the message and language tag without checking the
    remaining length, so a short/truncated STATUS packet over-read the buffer.
  - tACLItem.EncodeLength was rewritten as a two-pass nil-buffer sizing pass; the
    original computed a length that did not match what it then wrote.
  - SetExtended excluded vfaOwnerGroup where it meant vfaExtended.
  - Two `Exception.Create(...)` statements that were constructed but never
    RAISEd (so the error was silently swallowed).
  - ReadPacket busy-spun forever on `repeat until lLen > 4` with no state check:
    if the channel closed mid-read the client pegged a core and never returned.
    It now raises when State <> csConnected and yields with TThread.Sleep(1).
    This matters more than it looks - see section 6 on how a refusal surfaces.


================================================================================
4. SERVER  (TstSFTPServerSubSystem)
================================================================================

PUBLISHED PROPERTIES
  RootDir                   physical directory that becomes the client's "/".
  ReadOnly                  refuse every mutating request with
                            SSH_FX_PERMISSION_DENIED.
  PerUserSubDir             jail each user into RootDir\<username> (default
                            False).
  RequireUserAuthorization  refuse to serve unless the SSH server has a
                            TstSSHServerUsers attached (default TRUE - see
                            section 6).
  OnResolveRoot             last word on the jail root for a connection;
                            overrides the above.

IMPLEMENTED REQUESTS
  INIT, OPEN, CLOSE, READ, WRITE, LSTAT, FSTAT, SETSTAT, FSETSTAT, OPENDIR,
  READDIR, REMOVE, MKDIR, RMDIR, REALPATH, STAT, RENAME (incl. the v5
  ATOMIC/OVERWRITE flags).
  Responses: VERSION, STATUS, HANDLE, DATA, NAME, ATTRS.

DELIBERATELY REFUSED
  SYMLINK and READLINK answer SSH_FX_OP_UNSUPPORTED ("symbolic links are not
  supported"). This is not laziness: a symlink is the most direct way out of the
  jail, and CREATING one on Windows requires SeCreateSymbolicLinkPrivilege, which
  would break the no-special-privileges property in section 5. Any unrecognised
  opcode also gets SSH_FX_OP_UNSUPPORTED rather than a dropped connection.

WHY THE WIRE CODEC IS SELF-CONTAINED (tSFTPWriter / tSFTPReader / tSFTPAttrs
inside the unit, instead of reusing tFileAttributes3/5): the shared attribute
classes model permissions as a Delphi SET (tPermissionFlags), and a set cannot
express the POSIX S_IFMT type bits. A protocol-3 client has no separate type
byte - it distinguishes a directory from a file ONLY by S_IFDIR/S_IFREG in the
mode word. Without those bits, `ls` shows everything as a regular file and
recursive clients break. Hence:

    cModeDir  = cS_IFDIR or $1ED;    // 040755
    cModeFile = cS_IFREG or $1A4;    // 0100644

The writers are growable and self-contained, which also keeps the server free of
the client-side transport's request-correlation machinery.

DIAGNOSTICS: the global SFTPServerTrace callback is opt-in (nil by default) and
prints the negotiated version, each request, and jail decisions.


================================================================================
5. THE JAIL, AND WHY NO SPECIAL PRIVILEGES ARE NEEDED
================================================================================

DESIGN: single identity, no impersonation. Every file operation runs as the
server process's own account, no matter which SSH user is authenticated.
Confinement is by PATH, enforced in tSFTPJail, not by the OS access-control
system.

tSFTPJail CARRIES NO ALGORITHM OF ITS OWN. It is a thin adapter over
stFileJail, the library's single filesystem confinement primitive, which is
documented in full in FileJail.txt. Two implementations of a security boundary
is one more than a library should have.

The policy this subsystem asks for:

  RULE SET   cJailRulesLegacy - wildcards and redirection characters, NUL, ':'
             and the Windows separator inside a segment, and any ".." below the
             root. Device names and 8.3 shapes are deliberately NOT refused,
             because an existing client may legitimately hold such a name.
  EXTENSION  emUngated - no extension dimension at all. An SFTP jail root IS the
             authenticated user's own home, so the kind of a file carries no
             meaning here and refusing one by its suffix would be theatre.
  ACCESS     read, write, list and delete. Read-only enforcement is a separate,
             higher-level decision made by the ReadOnly property: the jail
             answers "is this path inside", the subsystem answers "is this
             operation allowed".

ONE DELIBERATE STRICTNESS. A segment with a trailing dot or space is refused on
Windows. Win32 strips those at open time, so a name validated with one and
opened without it is a name nobody approved.

Four jail-escape refusals are asserted in the self-test (section 7), and the
primitive itself carries a much larger hostile-vector corpus (FileJail.txt
section 12).

  SHARE MODE  jsmDenyWrite - single writer, multiple readers. This reproduces
              what the subsystem effectively had: a read open denied writers, so
              a read and a write of one file could never overlap. Windows
              enforces this; POSIX ignores it, having no mandatory equivalent.

FILE DATA IS NOT SUBJECT TO A CHECK-THEN-OPEN RACE. A confinement decision
about a NAME expires the moment it is made - between the check and the open,
anything able to write the tree can substitute a link for a directory, and the
name that was approved and the object that is opened are then two different
things. stFileJail closes that by keeping the object: SSH_FXP_OPEN of an
existing file takes its stream from the jail, so the descriptor that was
verified is the descriptor every subsequent SSH_FXP_READ and SSH_FXP_WRITE uses.
The handle model above holds one stream for the life of an SFTP handle, and the
jail is where that stream is opened.

WHAT IS STILL NAME-BASED, and why it is a smaller exposure:

  CREATION AND       A verifying open cannot resolve a name for an object that
  TRUNCATION         does not exist yet, and a truncating open is a create. The
                     path, or the nearest parent that exists, is checked on disk
                     first, and the file is checked again once it is open, so
                     nothing is written to one a link redirected; the create or
                     the truncation itself is what a lost race can redirect.
  ONE-SHOT REQUESTS  SSH_FXP_STAT, REMOVE, RENAME, MKDIR, RMDIR and directory
                     enumeration each act on a path once. The path is checked on
                     disk just before, so a link already in the tree cannot take
                     it out of the root; losing a race with one put in between
                     leaks metadata or misdirects a delete - it does not
                     disclose file contents.

Closing those races needs the POSIX *at family - stFileJail's handle already
carries the parent directory descriptor and leaf name for exactly that - and
Windows has no equivalent, so it would be a platform-asymmetric change
(section 9).

PLATFORM. The server runs on Windows and on Linux. Two things make that
possible:

  THE CIPHER SET. stRijndaelBase and st3DES carry bare `asm` code with no
  pure-Pascal path, and the Linux64 compiler rejects ASM outright, so the legacy
  units stRijndael and st3DES cannot be linked there at all. stTwoFish and
  stSHACAL link, but their block functions exist only in x86 and x64
  assembler, so there TwoFish raises eCipherError and SHACAL-2 is not
  registered. A POSIX build registers stAes + stAESNI instead, which is what
  an SSH peer negotiates in practice anyway.

  THE INTEGER TYPES. LongWord and LongInt are 32-bit on every Windows target but
  64-BIT on 64-bit POSIX, where Delphi widens them to match C's `long`. Every
  SSH and SFTP wire value is a uint32, so the whole wire-facing set now says
  UInt32 and Int32 explicitly. Left as LongWord, a length prefix byte-swaps as
  eight bytes instead of four and every frame is corrupt.

ATTRIBUTES ARE NOT SYMMETRIC BETWEEN THE TWO. On POSIX the real st_mode goes on
the wire unchanged - SFTP permission bits ARE POSIX mode bits, including the
type bits a v3 client needs to tell a directory from a file. Windows has no
POSIX mode, so one is SYNTHESISED from the read-only attribute, and a SETSTAT
can only move that single bit back; the other eight have nowhere to go.

WINDOWS PRIVILEGES: none required. Specifically NOT needed -
  SeTcbPrivilege / SeAssignPrimaryTokenPrivilege - would be required to
      impersonate the authenticated user; we never do.
  SeCreateSymbolicLinkPrivilege - would be required by SSH_FXP_SYMLINK; refused.
  SeRestorePrivilege / SeBackupPrivilege - would be required to bypass ACLs or
      preserve ownership; we do neither.
  SeSecurityPrivilege - would be required to read/write SACLs; v5 ACL support is
      limited to what the ordinary DACL API exposes.
Nor is a privileged port involved: Windows has no reserved-port restriction, and
in any case the listener belongs to the SSH server, not to this subsystem.

THE TRADE-OFF, STATED PLAINLY: because there is no impersonation, the OS cannot
enforce per-user access - the jail is the ONLY boundary, and every SFTP user has
the same effective rights inside it. PerUserSubDir gives each user a separate
directory, but that is a path-level separation maintained by this code, not a
kernel-enforced one. Run the server as a low-privileged account whose own ACLs
already limit it to the intended tree, so that the OS is a second line of
defence behind the jail rather than the jail being the only one.


================================================================================
6. AUTHORIZATION  (how a user is - or is not - allowed to use SFTP)
================================================================================

The SSH layer's per-user grant is tUserItem.SubSystems, checked through
TstCustomSSHServer.SupportsSubSystem -> tSSHServerUsers.AuthSubSystem ->
tUserItem.SupportsSubSystem.

THE FALL-THROUGH: SupportsSubSystem applies that grant only "if Assigned(fUsers)".
On a server with NO TstSSHServerUsers component, a bare controller match is
sufficient and EVERY authenticated user reaches EVERY registered subsystem. This
is reachable in practice, not theoretical - publickey auth validates against
ClientKeys without consulting the user list at all, and password auth can be
satisfied by an OnSetClientPassword handler. (Password auth with neither users
nor that event does raise, so that single path fails closed.)

That behaviour is BY DESIGN at the SSH layer and must not be "fixed" centrally:
the server cannot know how a given subsystem authorizes its callers. Snif and
Snip carry their own authentication and are therefore safe when exposed this
way. SFTP does not, so it takes the other branch of the contract:

  RequireUserAuthorization (default TRUE) makes NewSubSystem refuse and close the
  channel when Server.Users is nil - i.e. it declines to serve whenever the
  per-user grant cannot actually be enforced.

Set it False only if you are enforcing subsystem access some other way (e.g. an
OnAuthSubSystem handler). See SSH.txt section 8 for the full contract.

REGISTRATION ORDER GOTCHA: tUserItem.SubSystems.SelectedOptionNames selects among
ALREADY-REGISTERED option names. Assign the controller's Server property BEFORE
granting 'sftp' to a user, or the grant silently does nothing and the server
answers "refused the sftp subsystem request".

HOW A REFUSAL LOOKS ON THE WIRE: as a channel close, surfacing client-side as
eSFTPClientError rather than a clean protocol error. TstCustomSSHServer.
ExecuteSubSystem has ALREADY replied CHANNEL_SUCCESS by the time NewSubSystem
runs, so there is no protocol-level way left to say no at that point. The
client's ReadPacket handles the closed channel rather than spinning on it
(section 3), which is what makes a refusal surface as an error instead of a
hang.


================================================================================
7. TESTS
================================================================================

What the tests verified, and against which peers.

  OUR CLIENT <-> OUR SERVER in ONE process.
    GREEN ON WIN32 AND LINUX64.
    Covers the v3/v5 operation set, 4 jail-escape refusals, and two
    authorization cells. EVERY security-relevant assertion has a NEGATIVE
    CONTROL, because a test that cannot fail proves nothing:
      * subsystem grant: a second account with valid credentials but NO
        SubSystems grant must authenticate, must be able to open a session
        channel, yet must have "subsystem sftp" REFUSED.
        Negative control: grant that user 'sftp' and the check flips to FAIL
        with no exception raised.
      * unenforceable grant: a second server on port+1 with NO TstSSHServerUsers
        (OnSetClientPassword returning True) must still authenticate - which is
        what proves the section-6 fall-through is genuinely reachable - but must
        refuse SFTP.
        Negative control: set RequireUserAuthorization False and the check flips
        to FAIL.
    It ends with ExitProcess, not Halt: finalization AVs against the parked
    subsystem thread.

  LINKS IN THE SERVED FOLDER. The test builds its own fixture
    under the temp folder - a link out of the root, one whose target is gone,
    one that stays inside, a file link, and a root reached through a link -
    and asserts that the jail maps no path out of the root through any of
    them. A link that stays inside is followed on Windows and refused on
    POSIX, as the jail's two backends do. On Windows the links are junctions
    unless the process may make symbolic links; the file link needs Developer
    Mode or the privilege there, and is reported as skipped without it.
    GREEN ON WIN32, WIN64 AND LINUX64. Against the code before the fix it fails
    on Windows and on Linux.

  OUR SERVER AGAINST EXTERNAL CLIENTS. FIVE now pass the mkdir/put/ls/get/rm/
    rmdir round trip: OpenSSH `sftp`, PuTTY `psftp`, curl (libssh2), WinSCP
    and paramiko. All five negotiate SFTP version 3 - EVEN WinSCP, which
    supports higher. So protocol version 5 is exercised ONLY
    our-client<->our-server; no external client drives it. If
    you want v5 coverage against a third party, you need one that requests it
    (recent OpenSSH still speaks v3).

  curl (libssh2) - added 2026-07-20, PASSES the same round trip. Worth having
    because libssh2 is a THIRD implementation lineage, independent of both
    OpenSSH and PuTTY. Negative control verified: a wrong password gives
    exit 67 "Authentication failure" and creates nothing.

  WinSCP + paramiko - added 2026-07-20, both PASS. paramiko is a pure-Python
    SSH/SFTP stack (a FOURTH lineage, independent of OpenSSH/PuTTY/libssh2);
    its round trip is a Python script.
    Negative controls verified for both: a wrong password fails the connection
    and creates nothing (paramiko raises AuthenticationException -> exit 1).

  libssh2 KEX FLAKINESS (found via curl, characterized 2026-07-20). curl opens
    a FRESH SSH session per step (six per round trip), and libssh2/WinCNG
    intermittently fails KEX on a fresh connection - "Failure establishing ssh
    session: -8, Unable to exchange encryption keys", curl exit 2 - at roughly
    1 in 35 connections. Established facts:
      * It is BELOW SFTP: it happens before SSH_FXP_INIT, the server emits no
        exception to stderr and does not crash (the SFTP subsystem is never even
        created for that connection).
      * It is libssh2-SPECIFIC: the OpenSSH sftp client survives 80/80 identical
        rapid reconnects against the same server; only libssh2 trips it, and
        OpenSSH vs libssh2/WinCNG negotiate different KEX algorithms.
      * It is unrelated to the SFTP work - it is an SSH-transport connection-
        ESTABLISHMENT robustness issue (resembles the known thread-lifetime
        races), exposed here only because curl reconnects so often.
    The curl cell therefore RETRIES this specific transient (bounded to 4
    attempts, matched on exit 2 + the "establishing ssh session" text so a real
    error is never retried away), and every retry is logged and surfaced in
    the cell's PASS note - so the suite is deterministic (0 failures in 8
    back-to-back runs) without hiding the phenomenon. Root-causing the KEX
    race is a separate SSH-layer investigation, not part of the SFTP work.

  OUR CLIENT AGAINST OPENSSH - THE OTHER DIRECTION (added
    2026-07-20): our CLIENT against the real OpenSSH sftp-server.exe.
    GREEN. Until this existed, every byte our client ever parsed had been
    produced by our own encoder, so a bug corrupting both sides identically
    would have gone unnoticed.
    It also covers a branch nothing else does: OpenSSH negotiates protocol
    version 3 where our server negotiates 5, so the v3 OpenFile overload
    (tFileOpenFlags3, no ACE mask) and the v3 attribute decoder get their
    first real workout here.
    The test starts a PRIVATE sshd on a loopback-only high port with its own
    host key, authorized_keys and config in a temp dir, all deleted afterwards.
    That is deliberate: authenticating against the system sshd would mean
    adding a key to the user's real authorized_keys, i.e. granting standing SSH
    access to the machine. No elevation is needed - sshd running as the
    ordinary user authenticates that same user by public key. Since
    sftp-server is NOT jailed, the test confines every path to a folder of
    its own and removes only what it created.

  FINDING - Windows sftp-server omits "." and "..". The self-test asserts that
    readdir returns them (our server does emit them); the Windows build of
    OpenSSH's sftp-server does NOT. Confirmed independently from two
    directions: the real OpenSSH sftp client running `ls -a` against that same
    server and directory lists the regular file alone, and curl's listing of
    OUR server does show "." and "..". So this is peer behaviour, not a
    decoding fault - the test against it therefore asserts only that the entries
    returned are well-formed, never that dot entries are present.

NOT YET COVERED: rclone and lftp as additional external clients. No external
client exercises SFTP v5 (all negotiate v3), so our v5 SERVER encoder is only
ever tested by our own v5 client.


================================================================================
8. GUI DEMOS  (Demos\Delphi 13\SSH\)
================================================================================
Two FMX demo applications, alongside the SSH Tunnel demos:

  SFTP Server\SFTPServer.dproj  - the jailed server (section 4) with a GUI:
    port / root directory / read-only / host-key type / cipher+MAC pickers, a
    user table, and a live activity log fed by SFTPServerTrace.
  SFTP Client\SFTPClient.dproj  - a browse / upload / download client: connect,
    then descend directories, download, rename, delete, make folders and upload.

Both follow the demo conventions: a code-built resourceless-FMX form (no .fmx)
scaled to the OS UI font via the shared ..\UIScale.pas, and a NON-VISUAL engine
unit that holds all the library usage (SFTPServerEngine / SFTPClientEngine) so
the API calls read independently of the GUI. They build against ..\..\..\..\
Source for Win32/Win64.

Two things the engines make explicit, both learned by building them:
  * A bare TstSSHSocketServer selects NOTHING by default - KEX, cipher and MAC
    option lists must be set (e.g. to AllOptionNames) or the handshake fails
    with "Key exchange failed". TsnipServer hides this; a raw socket server does
    not.
  * Directory detection is version-dependent. The permission set cannot carry
    the POSIX S_IFDIR bit, so the client reads type from iFileAttributes5.
    AttributeType at v5 and from the ls-style LongName ("d...") at v3 - v5
    dropped the longname column, so a longname-only test wrongly sees every v5
    entry as a file.

Verified by a console test driving TSFTPServerEngine <-> TSFTPClientEngine
through a full round trip (connect / v5 / upload / list / download+verify /
rename / delete / rmdir), and by launching both GUIs.

================================================================================
9. KNOWN GAPS & FUTURE WORK
================================================================================
  - Only protocol versions 3 and 5 are implemented. Versions 4 and 6 are not;
    a v4 client is negotiated down to 3 rather than served as 4 (section 2).
  - SSH_FXP_SYMLINK / READLINK refused by design (section 4).
  - SSH_FXP_EXTENDED: the client can send extended requests, the server answers
    SSH_FX_OP_UNSUPPORTED. No extensions (e.g. posix-rename@openssh.com,
    statvfs@openssh.com, the OpenSSH hardlink or fsync extensions) are
    implemented on either side.
  - No user impersonation, so no OS-enforced per-user access control
    (section 5).
  - File DATA is race-free (SSH_FXP_OPEN takes its stream from the jail), but
    creation, truncation and the one-shot requests - stat, remove, rename,
    mkdir, rmdir, directory enumeration - still act on a name that was checked
    a moment earlier. Closing that race needs the POSIX *at family, which
    stFileJail's handle already carries the parent descriptor for, and which
    Windows has no equivalent of (section 5).
  - v5 ACL support is limited to what the ordinary DACL API exposes; SACLs would
    need SeSecurityPrivilege.
  - The SFTP units are wired into ALL 14 package versions - StrSecIV170-370
    (runtime) and DStrSecIV170-370 (design) - and all 14 build GREEN with their
    own compiler, XE3 through Delphi 13, with zero implicit-import warnings.
    Note 180/190 DO carry SFTP: their documented reduced set omits only the
    Snif/Snip framework, not the StreamSec.SSH.* layer SFTP depends on.
  - macOS and iOS are untested. The server compiles for OSX64 and OSXARM64 but
    has only been RUN on Windows and Linux; the jail's Darwin path differs from
    the Linux one in both its O_* constants and in using F_GETPATH where Linux
    reads /proc/self/fd.

================================================================================
 END OF FILE
================================================================================