Foundational infosec course · module 1 of 4 · host & service hardening | CRS-LNX-01

Linux administration, systemd service sandboxing, and server hardening

Every web gateway, database engine, and model connector runs inside an operating system process governed by user identifiers, kernel capabilities, and socket bindings. Mastering defensive Linux administration gives an engineer direct visibility into listening ports, file permissions, and service boundaries before any application scanner is launched.

1. Kernel namespace confinement and network perimeter architecture

LINUX HOST CONFINEMENT ARCHITECTURE: NFTABLES PERIMETER & SYSTEMD SANDBOX (CRS-LNX-01) LINUX HOST CONFINEMENT ARCHITECTURE: NFTABLES PERIMETER & SYSTEMD SANDBOX (CRS-LNX-01) NFTABLES INGRESS PERIMETER 443/tcp TLS · allowed 22/tcp SSH Ed25519 (no root) 0.0.0.0:5432 → DROPPED Loopback 127.0.0.1:5432 KERNEL MOUNT & SYSCALL NAMESPACE · ProtectSystem=strict /usr · /etc · /boot (READ-ONLY) /home · /root (MASKED: ProtectHome=yes) /tmp (ISOLATED: PrivateTmp=yes) Confined unit: api-worker.service User=api-worker · NoNewPrivileges=yes CapabilityBoundingSet= (empty) SystemCallFilter=@system-service Writable: /var/lib/api-worker only
Host isolation architecture: inbound packet filtering in nftables blocks exposed internal sockets, while the systemd mount namespace locks operating system directories read-only around a single state folder.

2. Inspecting sockets, capabilities, and service units without guesswork

Unintended network exposure frequently starts when a database, cache server, or debugging agent binds to all network interfaces on 0.0.0.0 instead of the loopback address 127.0.0.1. Running ss -tulpen reveals the exact listening address, transport protocol, owning user identifier, and process descriptor for every open port on the machine.

Remote administration over Secure Shell (SSH) requires disabling password logins and direct superuser sessions inside /etc/ssh/sshd_config so brute-force dictionary traffic fails at the transport handshake. Administrators verify syntax with sshd -t prior to reloading the daemon while keeping an active recovery terminal open.

Modern Linux distributions include built-in kernel namespace and system-call confinement inside systemd unit files without requiring external container runtimes. Directives such as NoNewPrivileges=yes, ProtectSystem=strict, ProtectHome=yes, and an empty CapabilityBoundingSet= strip root escalation paths even if a worker process suffers a parser bug.

Essential Linux diagnostic and hardening commands for daily server verification
Command, Display Filter, or Primitive Observed Technical Artifact Operational Interpretation
ss -tulpenActive TCP and UDP listening sockets with process names and numeric user identifiersDetects internal databases or test servers accidentally bound to public network interfaces
sshd -T | grep -E 'permitroot|passwordauth'Effective parsed Secure Shell daemon authentication settingsConfirms that password authentication and direct superuser logins are turned off
systemd-analyze security app.serviceQuantitative exposure score and missing unit sandboxing directivesHighlights writable filesystem paths, unrestricted capabilities, and missing syscall filters
nft list rulesetActive netfilter tables, chains, and default policy countersVerifies that inbound traffic is dropped by default except on explicitly authorized ports
find / -perm -4000 -type f 2>/dev/nullAll binaries carrying the set-user-identifier (SUID) permission bitIdentifies privileged helper executables that could permit local privilege escalation

3. Laboratory practicum and transition to automated verification

STEP-BY-STEP LABORATORY PRACTICUM SEQUENCE (CRS-LNX-01) STEP-BY-STEP LABORATORY PRACTICUM SEQUENCE (CRS-LNX-01) 1. Socket & Process Audit ss -tulpen & capsh 2. OpenSSH Key Policy Ed25519 + root disabled 3. systemd Unit Sandbox ProtectSystem=strict 4. nftables & Audit Log Default-drop ingress
Sequential hardening sequence on a Linux server: enumerating active network sockets, locking down remote shell authentication, confining background daemons in systemd, and enforcing default-drop packet rules.

In an isolated virtual machine, the engineer creates a dedicated unprivileged account, applies the unit drop-in configuration shown below, and verifies with systemd-analyze security that filesystem mutation outside the state directory is rejected by the kernel.

# 1. Inspect listening sockets and verify zero unintended 0.0.0.0 bindings
sudo ss -tulpen

# 2. Harden /etc/systemd/system/api-worker.service.d/hardening.conf
[Service]
User=api-worker
Group=api-worker
NoNewPrivileges=yes
ProtectSystem=strict
ProtectHome=yes
PrivateTmp=yes
PrivateDevices=yes
ProtectKernelTunables=yes
ProtectControlGroups=yes
ReadWritePaths=/var/lib/api-worker
CapabilityBoundingSet=
SystemCallFilter=@system-service
SystemCallErrorNumber=EPERM

# 3. Reload unit definitions and measure the updated exposure score
sudo systemctl daemon-reload && systemd-analyze security api-worker.service

Manual host hardening establishes the operating baseline, whereas multi-node releases require continuous checks against configuration drift. On the INDRA platform, static configuration verifier TOOL-COD-05 inspects container definitions and server blocks automatically, while classes INJ-CMD and CLD-K8S-06 verify runtime confinement.

4. Engineering reference notes for module CRS-LNX-01

Preventing administrator lockout when hardening OpenSSH configurations

Before restarting the sshd service, the administrator tests the configuration file with sudo sshd -t, keeps the current privileged terminal session open, and verifies key-based login in a second separate terminal window.

Difference between running a daemon under a non-root user and enabling ProtectSystem=strict

A standard unprivileged user can still read world-readable files across /etc, write to shared /tmp directories, and invoke unguarded setuid binaries, whereas ProtectSystem=strict with NoNewPrivileges=yes mounts the operating system tree read-only inside an isolated mount namespace.

Binding a web worker to port 443 without granting full superuser privileges

Instead of starting the application daemon as root, the unit file grants only the single ambient capability AmbientCapabilities=CAP_NET_BIND_SERVICE or delegates external transport termination to a reverse proxy talking to 127.0.0.1.

Choosing SystemCallErrorNumber=EPERM instead of immediate process termination in seccomp filters

Returning EPERM causes blocked system calls to fail cleanly with a standard permission error in application logs, allowing engineers to diagnose missing unit allowances during staging tests without silent crashes.

Enterprise pilot packages and air-gapped delivery

Following free express diagnostics, engineering and compliance teams select one of three deployment packages executed entirely inside the organization network without cloud telemetry.
Package A · 3 business days

Perimeter posture, transport security & localization

Takes public domain names and reverse-proxy configurations as input, delivering a hardened header patch, self-hosted asset bundle, and a signed Streebog-256 verification passport.
Package B · 7 business days

Air-gapped interface verification (indra-core)

Takes OpenAPI schemas and an isolated staging container as input, delivering a thirty-class paired decoy assessment with zero false positives, compiled mcp-sentinel contracts, and a full ledger passport.
Package C · 10 business days

Autonomous agent runtime gate (MITR)

Takes mcp.json manifests and tool schemas as input, delivering compiled satisfiability policies and pre-socket parameter enforcement.
Evaluation & offline distribution

Request the offline kit or schedule a pilot

The offline wheel bundle (--no-index --find-links) and standalone verifier scripts are provided for isolated laboratory testing and enterprise pilot evaluations. Submit a work email below without page reload or write directly to af@isslab.ai.
Direct engineering contact: af@isslab.ai
INDRA Verification Stand Emblem
Institutional developer & operator · verifiable registry records

Institutional developer and platform operator

Autonomous Non-Profit Organization "Research Institute of System Synthesis" (OGRN 1267700083617, INN 9731161602, KPP 773101001, 18 Davydkovskaya Street, Suite VIII, Moscow, 121352). Under the Security 3.0 research and engineering program, the institute develops and operates the MITR runtime action gateway and the INDRA verification stand, publishes the monograph Proven Action, and maintains open Apache-2.0 software packages with zero outside subcontractors.
Institute: isslab.ru MITR gateway: asi5.ru OGRN 1267700083617 Free tools (6)