Agent on Windows Server
The agent runs on Windows Server too (tested on Windows Server 2025, and in CI on its runner): the same agent, the same configuration and the same directory, with Windows’ own mechanisms in place of the Unix ones. Desktop Windows isn’t a target: Windows 11’s Smart App Control, where it’s on, refuses to run a binary no publisher signed, and the agent isn’t signed by one.
Configuration
Section titled “Configuration”The settings are the agent’s, with Windows paths:
server = "https://ferritor.internal:7070"ca = 'C:\ProgramData\ferritor\ca.pem'cert = 'C:\ProgramData\ferritor\agent.crt'key = 'C:\ProgramData\ferritor\agent.key'
[[output]]dir = 'C:\ProgramData\ferritor\secrets\app'allow_disk = true # required: Windows has no tmpfsgroup = 'NT SERVICE\app' # who reads the files: an account or groupon_change = { command = ["powershell", "-NoProfile", "-Command", "Restart-Service app"] }
[[output.secret]]path = "billing/app/db-password"Single-quoted TOML strings keep the backslashes as they are.
app here is the application’s own Windows service. A Windows service has
no reload, so the example restarts it, which interrupts it: if the
application re-reads the files itself (watching ..data, or reading them
on each use), leave on_change unset.
What differs
Section titled “What differs”| Linux | Windows | |
|---|---|---|
| Who may read a file | its mode and group | an access list the agent sets on each file and directory, nothing inherited: the agent’s account, SYSTEM and Administrators everything; group (an account or group name, DOMAIN\name, NT SERVICE\app, BUILTIN\Users) reads a file whose mode gives the group read, and lists the directories |
| The directory | must be in memory, unless allow_disk |
always on a disk: allow_disk = true is required. Encrypt the disk (BitLocker) |
..data and the names |
symbolic links | Windows’ symbolic links, the same layout and the same one-rename swap. Making them takes the Create symbolic links privilege: LocalSystem (a service’s default account) and elevated administrators have it; for another account grant it (secpol.msc, Local Policies, User Rights Assignment), or turn on Developer Mode. Without it the agent refuses to start, saying so |
| A file held open | the old generation is removed at the next write | most Windows programs open files so they can’t be deleted: a generation one of its files is open in stays until it’s closed, and is removed at the first write after (logged meanwhile, never a failed write) |
| Its memory | undumpable (PR_SET_DUMPABLE) |
its process’s access list, and each of its threads’, lets its own account only wait for it, end it and query it, never read its memory, take over a thread or change a list; SYSTEM and administrators with SeDebugPrivilege still can. The token’s default access list says the same, so a thread started later gets it. An on_change command starts with the default list the token had before, like any other process of the account |
| Telling the application | a signal or a command | a command, an .exe found as the path given, else in the system directory, the Windows directory or PATH (never the current directory). Not a batch file (refused: run it through "cmd.exe", "/c"). Its output goes to the agent’s console if it has one, nowhere as a service |
| Stopping | SIGTERM, SIGINT | Ctrl+C, Ctrl+Break, the console closing, a shutdown; as a service, the service control manager’s stop |
| Reloading the config | the file or a template’s source edited (looked at every 5 seconds), or SIGHUP |
the same, but there’s no SIGHUP. Keep the config, and every template source, writable by SYSTEM and Administrators only (below): whoever can write it chooses what the agent writes where, and the command it runs |
| Templates | the file’s mode and group | the same access list as any file of the output (its mode’s group bits for group). The shell filter writes for POSIX shells: PowerShell quotes differently, so use another filter for what PowerShell reads |
Reading a consistent set works as on Linux: resolve ..data once, then
read the files under it.
Getting it
Section titled “Getting it”Each release has ferritor-agent-<version>-x86_64-pc-windows-msvc.zip
(the agent alone, x86_64; releases up to 1.2.0:
…-x86_64-pc-windows-gnu.zip), with nothing else to install (the C
runtime is linked in), verified like the CLI’s archives
(production). It isn’t signed by a
publisher, so SmartScreen asks first for a browser’s download; on Windows
Server there’s nothing else in the way.
Running it
Section titled “Running it”By hand, from a console: ferritor-agent.exe run --config C:\ProgramData\ferritor\app.toml
(or once), as on Linux; Ctrl+C stops it.
As a service, the same run command line, registered with
New-Service or sc.exe (not PowerShell’s sc alias). Started by the
service control manager, run reports to it and stops at its stop;
started any other way it’s a console program. From an elevated
PowerShell:
New-Item -ItemType Directory C:\ProgramData\ferritor -Force# Only SYSTEM and Administrators: the agent's key and config are in here.# By SID (*S-1-5-18 SYSTEM, *S-1-5-32-544 Administrators): the names are translated.icacls C:\ProgramData\ferritor /reset # drops any entry of its own: only what it inherits is lefticacls C:\ProgramData\ferritor /inheritance:r /grant:r "*S-1-5-18:(OI)(CI)F" "*S-1-5-32-544:(OI)(CI)F"icacls C:\ProgramData\ferritor /setowner "*S-1-5-32-544" # an owner may change the list, whatever it says$acl = Get-Acl C:\ProgramData\ferritor$sids = $acl.GetAccessRules($true, $true, [Security.Principal.SecurityIdentifier]) | ForEach-Object { $_.IdentityReference.Value } | Sort-Object -Uniqueif (Compare-Object @($sids) @('S-1-5-18', 'S-1-5-32-544')) { throw "other entries: $sids" }if ($acl.GetOwner([Security.Principal.SecurityIdentifier]).Value -ne 'S-1-5-32-544') { throw "wrong owner" }Copy-Item ferritor-agent.exe C:\ProgramData\ferritor\
New-Service -Name ferritor-agent-app -StartupType Automatic ` -BinaryPathName '"C:\ProgramData\ferritor\ferritor-agent.exe" run --config C:\ProgramData\ferritor\app.toml --log-file C:\ProgramData\ferritor\app.log'sc.exe failure ferritor-agent-app reset= 86400 actions= restart/5000Start-Service ferritor-agent-appor with sc.exe create ferritor-agent-app start= auto binPath= "…", the
same command line. Any service name works. --log-file is where the logs
go, appended, instead of stderr: a service has no console, so without it
nothing is logged. It runs as LocalSystem unless given an account
(-Credential, obj=): an account of its own needs the link privilege
granted, read access to the config, the key and the CA, and write access
to the output directory’s parent. To render once before the application
starts, run ferritor-agent.exe once --config … first, as ExecStartPre
does under systemd. Stop-Service ferritor-agent-app stops it: the files
stay as they are.
The agent’s own key file and config
Section titled “The agent’s own key file and config”The agent’s own key file isn’t the agent’s to protect: whatever
created it decides who can read it, and a folder under C:\ProgramData
inherits a list that lets every user read. Lock the folder down as above
before putting the key in it. The config needs the same, and so does
every template source it names: the agent
reloads them when they change, so
whoever can write them chooses what the agent writes where (and, for the
config, the command it runs).
Copy a new key or config into the folder (a copy, or a file created
there, gets the folder’s list), or move it in only once its list is right:
a moved file keeps the list it had and its owner, who may change that list
whatever it says, and the agent may reload a config before its list is
fixed. Keep template sources in the same folder, or lock down each
source’s own folder as above first: /reset gives a file its folder’s
list. Then check every file, each template source the config names
included (its full path, wherever it is):
foreach ($path in 'C:\ProgramData\ferritor\agent.key', 'C:\ProgramData\ferritor\app.toml', 'C:\ProgramData\ferritor\app.env.tmpl') { # and every other source icacls $path /reset # its folder's list: SYSTEM and Administrators icacls $path /setowner "*S-1-5-32-544" # Administrators icacls $path # check: exactly those two (Get-Acl $path).GetOwner([Security.Principal.SecurityIdentifier]).Value # S-1-5-32-544}Running as an account of its own (not LocalSystem), the agent needs to
read each of them: grant it read on each, nothing more (icacls $path /grant "DOMAIN\ferritor-agent:R"), and the check then shows that one entry
too. Write access stays with SYSTEM and Administrators.
A locked file is only as safe as the folders above it: whoever may rename
or delete one of them (or change its list, or owns it) can put a folder
of their own in its place, with a key, a config or a source of their
choosing, which the agent then reloads. C:\ProgramData’s own list is
fine as Windows sets it; a drive’s root other than C:\ usually isn’t
(its default lets users change the folders made in it). So check every
folder above each file, up to the drive: this prints nothing when only
SYSTEM, Administrators and TrustedInstaller may, and otherwise lock down
the folder it names as above.
$trusted = 'S-1-5-18', 'S-1-5-32-544', # SYSTEM, Administrators, TrustedInstaller 'S-1-5-80-956008885-3418522649-1831038044-1853292631-2271478464'$rights = [Security.AccessControl.FileSystemRights]'Delete, DeleteSubdirectoriesAndFiles, ChangePermissions, TakeOwnership'foreach ($path in 'C:\ProgramData\ferritor\agent.key', 'C:\ProgramData\ferritor\app.toml', 'C:\ProgramData\ferritor\app.env.tmpl') { # and every other source $dir = Split-Path $path while ($dir) { $acl = Get-Acl $dir $owner = $acl.GetOwner([Security.Principal.SecurityIdentifier]).Value if ($owner -notin $trusted) { "$dir is owned by $owner" } foreach ($ace in $acl.Access) { $sid = $ace.IdentityReference.Translate([Security.Principal.SecurityIdentifier]).Value if ($ace.AccessControlType -eq 'Allow' -and $sid -notin $trusted -and -not ($ace.PropagationFlags -band 'InheritOnly') -and ($ace.FileSystemRights -band $rights)) { "$dir lets $($ace.IdentityReference) $($ace.FileSystemRights)" } } $dir = Split-Path $dir }}