Skip to content

Hardening

l0-cache is designed for unattended operation on servers, containers, and CI systems. The following protections are in place.

Memory Safety

ThreatProtection
Binary file with no newlines (single 2 GB "line")Line length cap: 1 MB per line
--raw on command producing gigabytes of outputRaw mode cap: 256 MB, then drain without storing
head_cap + tail_cap arithmetic overflowsaturating_add throughout
usize::MAX passed to Vec::with_capacityRaw mode has dedicated path, no HeadTailBuffer

Process Safety

ThreatProtection
Child killed by signal (SIGKILL, SIGSEGV)Exit code 128+N (POSIX convention)
User presses Ctrl-C during long commandSIGINT ignored in l0-cache, child receives it via process group
`l0-cache cmdhead` closes pipe early
l0-cache killed before child.wait()Signal handlers prevent this scenario
/bin/sh missing (distroless container)Pre-spawn check with clear error message

I/O Safety

ThreatProtection
Invalid UTF-8 in command outputread_line_lossy() with String::from_utf8_lossy
Windows-style \r\n line endings (SSH from Windows)Stripped during line reading
$HOME not set (containers, cron, systemd)Fallback to /etc/passwd lookup via getuid()
Metrics file permissions in shared environmentschmod 0600 on every open
Metrics file growing unboundedAuto-rotation at 10 MB
Partial JSON write (process killed mid-write)Stats reader skips malformed lines
Concurrent writes from multiple l0-cache instancesO_APPEND mode (atomic for lines < PIPE_BUF)

What Is Not Protected

  • SSH without PTY: signals may not reach child. Use ssh -t.
  • Binary detection after 8 KB: late binary data is processed as text (lossy, not dangerous, but output may be noisy).
  • NFS/CIFS: O_APPEND atomicity is not guaranteed on network filesystems. Metrics may have interleaved lines in rare cases.