ipfence home page local-first intrusion prevention for Linux

Manual pages

Safety mechanisms

A program running as root that reads attacker-influenced text and changes the firewall must be careful. This page collects the protections in one place, each with where it lives.

For the threat-by-threat view see Privacy and threat model.

Files (internal/safepath)

Function Requires
OpenTrusted regular file, not a symlink or FIFO, owned by root or the current user, not writable by group or others. Used for the settings file and executables
EnsurePrivateDir a real directory owned by the current user, mode 0700, every parent trustworthy (not writable by others unless sticky, no untrusted symlinks)
CheckPrivateFile regular file owned by the current user with no access for others. Used for the database and lock
Lock exclusive writer lock

Log files use their own opener: no symlinks, no blocking, regular files only.

Untrusted input

Input Limit
sshd message 2 KiB, no control characters
journal JSON line 128 KiB
Nginx line 16 KiB
Caddy line 64 KiB
settings file 64 KiB
nginx configuration 64 files of 256 KiB
Docker reply 4 MiB
command output 1 MiB
control request 16 KiB

Regular expressions are linear-time. Parsers were fuzzed with millions of random inputs without a failure.

Resource bounds

State Limit
active bans 20,000
stored hits 50,000
offense records 100,000
history 10,000 rows, 90 days
proxied observations in memory 100
hook queue 16
reader notices 5 each
service memory 256 MiB (unit)
service tasks 128 (unit)

Firewall

One table; ownership proven structurally before every change; deny-only rules; allowlist inside every rule; loopback excluded twice; atomic batches; never flushes.

Fail directions

When something goes wrong, which way does it fail?

Failure Behaviour
database unreadable or corrupt refuse to start; file untouched; kernel rules stay
firewall write fails ban shown as not enforced; retried
table not provably ours read-only; reported
log unreadable detector degraded, visible
nginx configuration makes addresses untrustworthy detector stopped
saved journal position lost continue, report the gap
settings invalid refuse to start
cannot list local addresses keep the last list; report

The service sandbox

See Installation. The most visible guarantee: RestrictAddressFamilies=AF_UNIX AF_NETLINK means the kernel refuses any attempt to create an IPv4 or IPv6 socket. The end-to-end test traces the running daemon and fails if one appears. systemd's analyzer rated the unit's exposure 2.0 ("OK") on the test machine.

What has not been done

No independent security audit. The review behind these protections was done by the author of the code.