# Security baseline

> Falak audits every server daily (SSH, updates, firewall, Docker, files, kernel and more), scores it out of 100 and offers one-click fixes.

Source: https://falak.sh/docs/servers/security-baseline/

Since v0.10.0 the agent audits every active server **daily**, after provisioning, and on demand. Each server gets a **score** out of 100, a history, and fixes for what fails. **Security baseline** in the navigation lists every server's score; a server's **Security** tab shows its report.

## What is checked

| Area | Checks | Fix |
|---|---|---|
| SSH | Root login by password, password auth, empty passwords, `PermitRootLogin`, unknown authorized keys | Harden SSH (`50-falak.conf`, checked with `sshd -t`, rolled back on failure) |
| Updates | Pending security updates, unattended-upgrades on, reboot required | Turn on unattended updates; install now; reboot in a window |
| Firewall | nftables default deny active, unexpected listening ports on public interfaces, Docker publishing around the firewall | Apply the firewall again; close a port with a deny rule |
| Intrusion prevention | fail2ban active with the sshd jail | Guard SSH with fail2ban |
| Docker | Daemon on TCP without TLS, privileged containers, `docker.sock` mounted into containers | Turn off the Docker TCP socket; the others show the service |
| Files | Permissions of `.env` and secret files, world-writable files in site roots, executables in `/tmp` | Make secret files private |
| Kernel | `rp_filter`, `accept_redirects`, `tcp_syncookies`, `kptr_restrict` | Harden kernel network settings (`90-falak-hardening.conf`) |
| Accounts | Users with UID 0, sudoers with `NOPASSWD` outside Falak, shell users Falak doesn't know | Information only |
| Time | NTP sync | Keep the clock in sync (`systemd-timesyncd`) |
| Backups | Databases without backups, no drill | A link to the page |

Each check has a status (`pass`, `warn`, `fail`, `info`) and a severity (`critical`, `high`, `medium`, `low`, `info`), with the evidence the agent found. The audit only reads the machine.

## The score

**Score** = 100 minus the cost of every failing check (critical 30, high 15, medium 5, low 2) and warning (critical 15, high 7, medium 2, low 1), never below 0. A server is **Production ready** when no check of high or critical severity fails.

## Fixes

- **Fix** next to a finding applies that fix; **Fix all safe** applies every fix marked non-disruptive at once.
- **Disruptive** fixes ask for confirmation one by one: hardening SSH, installing updates (services may restart), rebooting (you pick the time, in server time) and turning off Docker's TCP socket (which restarts Docker).
- Every fix comes from an **allowlist compiled into the agent**: the control plane can't send arbitrary commands. Each fix is idempotent and backs up every file it touches.
- **Applied fixes** with a backup can be **undone for 7 days** from the Security tab.

The server is audited again once a fix settles.

## Alerts

| Alert type | When | Severity |
|---|---|---|
| `security.score_dropped` | The score dropped by 10 points or more | warning |
| `security.critical_finding` | A new high or critical finding | critical |
| `security.unexpected_port` | A new public port nobody expected | warning |

They carry a **Fix in baseline** action and are part of the [default rule pack](/docs/observability/alerts/#default-rule-pack).

## Permissions

| Action | Permission | Roles |
|---|---|---|
| View reports | `security.view` | owner, admin, developer, viewer |
| Run audits, apply and undo fixes | `security.fix` | owner, admin |

API: [`GET /api/v1/servers/{server}/security`](/docs/api/servers/#security-baseline).

## Next steps
