Contents · Forum Home · StreamSec Tools 4.1.5.363 documentation

stFileJail.Windows

Windows half of the stFileJail verification backend. The POSIX half is
  stFileJail.Posix; both declare the same descendant contract and stFileJail
  selects one in its implementation uses clause.

  THE WHOLE UNIT IS WRAPPED IN AN MSWINDOWS CONDITIONAL so it compiles to a legal
  empty unit elsewhere and can sit unconditionally in every StrSecIV package
  contains clause - the arrangement StreamSec.Mobile.AsyncTLSListener.Posix
  already uses.

  HOW THE CHECK WORKS. Open the object following every reparse point, then ask
  the OS what was actually opened, then compare that against the root resolved
  through the IDENTICAL call. Both sides are then OS-produced strings in the
  same '\\?\' domain, which disposes of four separate problems at once: the
  '\\?\' prefix, 8.3 aliasing, on-disk casing, and subst / mount-point
  rewriting. Lifting the root up into the target's domain is right; normalising
  the target down into the root's domain is not, because that means parsing
  OS truth with our own string code.

  WHY THE PATHS PASSED TO CreateFileW CARRY A '\\?\' PREFIX. It lifts MAX_PATH,
  and - the part that matters here - it DISABLES Win32 path normalisation. An
  un-prefixed path is normalised on the way in, which strips trailing dots and
  spaces, so the name the kernel opens is not the name the jail validated. The
  prefix is what makes 'validate what you open' true rather than aspirational.

  WHAT THIS BACKEND CANNOT DO. Windows has no openat family, so the parent
  directory descriptor on tJailHandle is left closed and a delete is by name.
  That is a residual race, and it is stated rather than papered over.

Feature notes: File jail (filesystem confinement) notes

Classes, interfaces and records

classtWindowsJailVerifier

inherits from tJailVerifier

function OpenRoot(const aRoot: string; out aHandle: tJailHandle; out aVerdict: tJailVerdict): Boolean; override; function OpenAt(const aRoot: tJailHandle; const aRelative: string; aAccess: tJailAccessSet; aOptions: tJailOptions; aCaseMode: tCaseMode; aShareMode: tJailShareMode; out aHandle: tJailHandle; out aVerdict: tJailVerdict): Boolean; override; function NewStream(var aHandle: tJailHandle; aAccess: tJailAccessSet; out aStream: TStream; out aVerdict: tJailVerdict): Boolean; override; procedure Close(var aHandle: tJailHandle); override;