Skip to content

Secrets

This page lists the secrets to keep and how to protect them on the servers.

Secrets to keep

Keep these secrets in a vault.

Secret Purpose
Backend KEK Protect encryption keys used by Platform and its workers
Frontend KEK Protect Frontend keys
PostgreSQL passwords Authenticate each component's role on its databases
Provider keys Authenticate model and connected service calls
admin account password set during activation Administer SmartAGT. The one-time password from init is replaced at first login

Backend processes share the Backend KEK, the Frontend has its own. These keys must be kept across restarts: replacing a package must preserve access to databases, files and encryption keys.

Protect the secrets

The KEKs and the passwords of the PostgreSQL roles live only in the environment of the services:

  • never in a YAML file, a script or a shared file
  • typed without display, never as a command argument, which would stay in the history
  • in a console closed once the operation is done
  • readable by administrators only

The environment files are restricted to root at installation. Check it:

sudo stat -c '%a %U %n' /etc/smartagt/backend.env /etc/smartagt/bff.env

Expected result: every file shows 600 root.

The environment of a service is stored in its registry key, readable by default by every user of the server. Restrict these keys to administrators and the system:

$names = 'SmartAGT-Platform-Service', 'smartagt-rag-ingestor-worker', 'smartagt-rag-embed-worker', 'smartagt-scheduler-worker', 'SmartAGT-AI-Gateway-Service', 'smartagt-frontend-service'
foreach ($name in $names) {
    $key = [Microsoft.Win32.Registry]::LocalMachine.OpenSubKey("SYSTEM\CurrentControlSet\Services\$name", 'ReadWriteSubTree', 'ChangePermissions, ReadPermissions')
    $acl = $key.GetAccessControl()
    $acl.SetAccessRuleProtection($true, $false)
    foreach ($rule in @($acl.Access)) { [void]$acl.RemoveAccessRule($rule) }
    foreach ($sid in 'S-1-5-32-544', 'S-1-5-18') {
        $acl.AddAccessRule((New-Object Security.AccessControl.RegistryAccessRule((New-Object Security.Principal.SecurityIdentifier $sid), 'FullControl', 'ContainerInherit', 'None', 'Allow')))
    }
    $key.SetAccessControl($acl)
    $key.Close()
}

Expected result: (Get-Acl HKLM:\SYSTEM\CurrentControlSet\Services\SmartAGT-Platform-Service).Access lists only BUILTIN\Administrators and NT AUTHORITY\SYSTEM.

Apply this check on every node, for the services it carries.

The environment files are restricted to root at installation: backend.env on the Backend nodes, bff.env on the Frontend nodes. Check it:

sudo stat -c '%a %U %n' /etc/smartagt/*.env

Expected result: every file shows 600 root.

The environment of a service is stored in its registry key, readable by default by every user of the server. Restrict these keys to administrators and the system. The loop only handles the services present on the node:

$names = 'SmartAGT-Platform-Service', 'smartagt-rag-ingestor-worker', 'smartagt-rag-embed-worker', 'smartagt-scheduler-worker', 'SmartAGT-AI-Gateway-Service', 'smartagt-frontend-service'
foreach ($name in $names | Where-Object { Test-Path "HKLM:\SYSTEM\CurrentControlSet\Services\$_" }) {
    $key = [Microsoft.Win32.Registry]::LocalMachine.OpenSubKey("SYSTEM\CurrentControlSet\Services\$name", 'ReadWriteSubTree', 'ChangePermissions, ReadPermissions')
    $acl = $key.GetAccessControl()
    $acl.SetAccessRuleProtection($true, $false)
    foreach ($rule in @($acl.Access)) { [void]$acl.RemoveAccessRule($rule) }
    foreach ($sid in 'S-1-5-32-544', 'S-1-5-18') {
        $acl.AddAccessRule((New-Object Security.AccessControl.RegistryAccessRule((New-Object Security.Principal.SecurityIdentifier $sid), 'FullControl', 'ContainerInherit', 'None', 'Allow')))
    }
    $key.SetAccessControl($acl)
    $key.Close()
}

Expected result: on every node, Get-Acl on the key of a SmartAGT service lists only BUILTIN\Administrators and NT AUTHORITY\SYSTEM.

Going further