Expand description
Secrets on a Windows VM, in PowerShell. Delivery keeps each value under KEPT_DIR, a
folder only SYSTEM and Administrators can open, and leaves the mark DELIVERED the set-up
waits for; each file is then written at its path with the same two readers and nobody else.
The values come on the connection’s standard input (WinRM’s or OpenSSH’s), after the
receiving script itself: the command line the runner starts is BOOTSTRAP, the same
for every machine, which reads the script’s first line and runs it. Nothing of a value is
in a command line, a generated file or the output.
At every boot a startup task (isoloom-apply-secrets) writes the files again. Task
Scheduler starts the startup tasks in no fixed order, so the before and command scripts
run the same placing script first themselves: their process never starts without its files.
Constants§
- BOOTSTRAP
- What the runner starts on the machine (as
powershell -EncodedCommand): it reads the first line of its standard input, the receiving script in base64, and runs it. The script reads the values from the lines that follow. - DELIVERED
- The mark delivery leaves once every secret is kept.
- KEPT_
DIR - Where a Windows machine keeps the secrets delivered to it.
- PLACE_
SCRIPT - The script putting the files in place, run by the startup task and before the process.
- PLACE_
TASK - The startup task running
PLACE_SCRIPTat every boot.
Functions§
- command_
line - The command line running
BOOTSTRAPthrough a remote shell (OpenSSH’s):powershellandpowershell_args, none of which a shell changes. - from_
environment - A Windows VM’s
Secretsstep when the tool that runs it hands the values over itself (Vagrant’s provisioner environment over WinRM): each ofvalues, a secret’s name and the variable holding its value in base64 (PowerShell never expands anything in it), kept in the SYSTEM- and Administrators-only folder and the delivery marked; then the placing script written, registered and run, asstepdoes. Nothing waits. An empty or unset variable writes an empty value the first time, and keeps the value already kept after. - input
- What the deliverer writes on the connection’s standard input: the receiving script in
base64 on the first line, then
values(one base64 line per secret, innames’ order). - path
- The path of a secret file on Windows: a drive path as it is, a path from
/on drive C:. - place
- Each kept secret written at its path, its folder made when missing. The file is created empty and limited to SYSTEM and Administrators before the value is written into it, so it never holds the value with its folder’s (wider) access list.
- place_
first - The line a
beforeor command script starts with on a machine that gets secrets: the files put in place first, whichever startup task Windows ran first. - powershell_
args - The arguments of
powershell.exerunningBOOTSTRAP, encoded (UTF-16LE in base64) so that no remote shell (cmd, PowerShell) reads anything into it. - receive
- The receiving script. After the line that holds it, its standard input holds one line per
secret of
names, in that order, each value in base64; it keeps each one, marks the delivery, then putsfilesin place (so a run again refreshes them). - step
- A Windows VM’s
Secretsstep: the wait, then the placing script written, registered as a startup task (as SYSTEM) and run now. - wait
- Waits for the delivery mark, saying so once; fails after
DELIVERY_TIMEOUTseconds with what to do.