Skip to content

Confine the services

This page restricts the rights of the SmartAGT services on a Linux server and reserves their logs to the service account. The settings are added to the installed units, without modifying them.

Prerequisites

Procedure

1. Create the override

On each server, create this file for each SmartAGT service present: SmartAGT-Platform-Service, smartagt-rag-ingestor-worker, smartagt-rag-embed-worker, smartagt-scheduler-worker, SmartAGT-AI-Gateway-Service and smartagt-frontend-service.

sudo systemctl edit <service>
[Service]
NoNewPrivileges=yes
ProtectSystem=strict
ProtectHome=yes
PrivateTmp=yes
PrivateDevices=yes
ProtectKernelTunables=yes
ProtectKernelModules=yes
ProtectKernelLogs=yes
ProtectControlGroups=yes
ProtectClock=yes
ProtectHostname=yes
ProtectProc=invisible
RestrictSUIDSGID=yes
RestrictRealtime=yes
RestrictNamespaces=yes
LockPersonality=yes
CapabilityBoundingSet=
AmbientCapabilities=
RestrictAddressFamilies=AF_INET AF_INET6 AF_UNIX
SystemCallArchitectures=native
SystemCallFilter=@system-service
UMask=0027
StateDirectoryMode=0750
LogsDirectoryMode=0750

The service only writes to its data directory and its log directory, already declared by the unit.

Expected result: systemctl cat <service> shows the unit followed by override.conf.

2. Restart and check

sudo systemctl daemon-reload
sudo systemctl restart <service>
systemd-analyze security <service>

Expected result: the service is active, its log contains neither Permission denied nor Read-only file system, and the exposure score goes down.

Port below 1024

If you placed a listener on a privileged port, for example 443 (Change the ports), replace the two capability lines with:

CapabilityBoundingSet=CAP_NET_BIND_SERVICE
AmbientCapabilities=CAP_NET_BIND_SERVICE

Logs

Permissions

With the override, new log files are readable by the service account and its group only. On an existing installation, fix the files and directories already created once:

sudo find /var/log/smartagt -type f -exec chmod o-rwx {} +
sudo chmod 0750 /var/log/smartagt/backend /var/log/smartagt/bff /var/lib/smartagt/backend /var/lib/smartagt/bff

Do not remove the rights of the parent directory /var/log/smartagt: the services must traverse it.

Expected result: sudo ls -l /var/log/smartagt/backend shows files as -rw-r-----.

Structured output

The services also write their logs to their output, collected by journald. For JSON output, one line per event, add to the component YAML, then restart its services:

smartagt:
  core:
    logging:
      json_format: true

Each line carries the timestamp, the level, the component, the correlation identifier and the message. The app.log and access.log files also switch to JSON. Only the first configuration loading line stays as text. Your collection agent or rsyslog then relays journald to your SIEM.

Expected result: journalctl -u SmartAGT-Platform-Service -o cat -n 5 shows JSON lines.