sys-lib reads facts about the machine for the program that links it. Most of what it reads comes from places the program does not control: /proc and /sys inside a container whose image or orchestrator may be hostile, firmware tables, the registry, the environment, and files such as /etc/os-release. A reading that panics, hangs, or allocates without bound on such input takes the calling service down with it, so for sys-lib that is a security bug, even when memory safety holds.
Report a vulnerability privately through GitHub's security advisories for jamesgober/sys-lib, or by email to me@jamesgober.com. Please include the platform, the version, the features in use, and the input (a file's content, a mount table) that triggers it.
- No panic on any input. Every reading returns a value that keeps its invariants or an error. Every parser is safe Rust, bounded, without recursion, fuzzed, and run under Miri.
- No hang. Network filesystems are never touched by default; Windows volume calls run with critical-error dialogs off; a FIFO where a file is expected is opened without blocking and refused.
- Bounded memory. Every file read has a budget (1 MiB), every list a count limit checked before allocating, and every size-then-fill system call at most three tries; past a budget the answer is
TooLarge. - No subprocess. No reading starts a program, so a planted
PATHcannot change an answer. Only the build helper runsgitand$RUSTC, at build time. - No identifier leaves
device. Raw hardware identifiers live in a fixed buffer, wiped after hashing; errors,Debug,Display, and reports carry none. unsafeonly at the system-call boundary. It is confined to the platform modules, one operation per block, each with aSAFETYcomment (both enforced by clippy). Every C struct has a size, alignment, and field-offset check against the platform headers on every target.
The full model, with the attackers considered, is in dev/PLAN.md section 14.
| Id | Threat | Defence | Cost | Test |
|---|---|---|---|---|
| T1 | Raw hardware identifiers disclosed through logs, errors, Debug, Display, or the API |
raw values exist only inside device, in a fixed buffer wiped after hashing; Error carries no values; summary() has no identifiers |
one wipe of a 256-byte buffer per identifier read | test_attack_t1_no_output_contains_a_raw_identifier, test_attack_t1_fingerprint_debug_names_anchors_only |
| T2 | One device id correlated across applications | a keyed hash with a key derived from the application id; an optional secret | one key derivation per call, inside the device::id figures in docs/PERFORMANCE.md |
test_attack_t2_applications_see_unrelated_fingerprints |
| T3 | A device id used to authenticate a machine, then spoofed | documentation; nothing in the API implies verification | none | test_attack_t3_the_warning_is_in_the_documentation |
| T4 | Paths or values injected through the environment (TZ=../../etc/shadow, a hostile LANG, a HOST_PROC-style redirect) |
no root override from the environment; TZ, LC_*, and LANG validated and never used to open a file; guard and interface names validated |
a validation of a few bytes | test_attack_t4_hostile_environment_changes_no_answer |
| T5 | Files that change between reads, and pids reused | only /proc/self and /proc/1 are read, plus, when the guard refuses to start, the start time of the process its pid file names; one open per file, read to the end; combined values clamped to their invariants |
a few comparisons per reading | test_attack_t5_values_read_at_different_instants_keep_invariants, test_attack_t9_pid_names_only_a_process_that_can_hold_the_lock |
| T6 | Hostile /proc and /sys in a container: huge or negative numbers, binary junk, enormous files |
safe, bounded, checked parsers without recursion; a fuzz target for every parser | none measurable | test_attack_t6_hostile_values_in_every_file_never_panic, test_attack_t6_hostile_brand_strings_clean_in_bounded_time, the fuzz targets |
| T7 | Resource exhaustion through huge files or lists (100 000 mounts, 4 096 CPUs) | a 1 MiB budget per file; list budgets (4 096 mounts and interfaces, 16 384 CPUs) checked before allocating; the mount lookup streams the table with a 16 MiB budget | none in the normal case | test_attack_t7_oversized_files_and_lists_are_too_large |
| T8 | Hangs on a dead network filesystem, a FIFO, or a removable drive | network filesystems skipped by default; files outside /proc and /sys opened non-blocking and required to be regular files; critical-error dialogs off around Windows volume calls |
one fstat per file opened outside /proc and /sys |
test_attack_t8_network_mounts_are_never_listed_by_default, test_linux_root_fifo_does_not_block |
| T9 | Attacks on the guard's lock file: a symbolic link at the lock path, a lock file planted first, a directory other users can write to, a lock file deleted while held, a pid that names another program | the lock directory must belong to this user and be closed to others (mode and owner on Unix, the access list on Windows) and is created that way; no-follow open; the locked file checked against the path; on Windows the held file cannot be deleted; a reported pid must name a running process that started before its pid file was written | one stat and one fstat when the guard starts (about 2 µs); on Windows one access-list check |
test_attack_t9_symlinked_lock_file_is_refused, test_attack_t9_writable_lock_dir_is_refused, test_attack_t9_symlinked_lock_dir_is_refused, test_attack_t9_windows_lock_dir_is_private_and_checked, test_attack_t9_pid_names_only_a_process_that_can_hold_the_lock, test_guard_is_held_until_the_lock_file_is_replaced, tests/guard.rs |
| T10 | The guard's umask change racing other threads | the guard runs before threads; it warns when more are running; the umask is set once | one file read when the guard starts | test_attack_t10_guard_after_threads_warns_and_sets_the_umask_once |
| T11 | Build and instance information disclosing the build host, user, or source path | BuildInfo::public(); no build host, user, or path recorded; values validated before rustc-env |
none at run time | test_attack_t11_nothing_records_host_user_or_path, test_attack_t11_public_shows_name_and_version_only, test_attack_t11_writers_escape_hostile_values |
| T12 | Memory-safety bugs at the system-call boundary: wrong layouts, overruns in size-then-fill loops, leaked handles or references | unsafe confined to the platform modules; layout checks on every target; at most three tries per size-then-fill loop; lengths checked before slicing; release on drop; the owners of CoreFoundation, IOKit, and Mach objects are unsafe fn |
none | test_attack_t12_no_reading_holds_a_descriptor, the layout tests, Miri on the parsers, the AddressSanitizer job (Linux, macOS), the soak run |
| T13 | Identifying values (host name, user, MAC address) leaving the machine in logs | documented as identifying; excluded from summary(); the readiness report shows no mount source |
none | test_attack_t13_summary_has_no_identifying_values, test_readiness_display_cannot_be_forged_and_names_no_source |
| T14 | A spoofed environment (KUBERNETES_SERVICE_HOST, a planted /.dockerenv, fake DMI strings) |
detection is advisory, every piece of evidence carries its strength, and the docs forbid security decisions on it | none | test_attack_t14_environment_is_weak_evidence |
| T15 | Malformed firmware tables: bad lengths, missing terminators, structure loops | a bounded SMBIOS parser: each structure checked against the table end, at most 4 096 structures, no recursion; a drive's product string ends at the next field | none | test_attack_t15_hostile_smbios_tables_stop_cleanly, the smbios fuzz target |
| T16 | A planted program run in place of a system tool (PATH with a fake lsb_release) |
no subprocess at run time | none | tests/attack_t16_subprocess.rs, the CI check that src/ starts no program |
Before each release, every fuzz target runs for 24 hours (five chained rounds on GitHub's runners, fuzz.yml with long), and the soak run (bench/src/bin/soak.rs) calls every reading in a loop and fails if this process's memory or open descriptors grow.
For 0.8.0:
| Run | Where | Length | Result |
|---|---|---|---|
| Soak | Linux (ubuntu-latest) |
5 h 40 min, 20 349 rounds | no growth: 3.3 MiB resident and 5 descriptors from start to end |
| Soak | macOS (macos-latest) |
5 h 40 min, 18 743 rounds | no growth: 7.3 MiB at the warm-up peak, at most 6.9 MiB after; 10 descriptors |
| Soak | Windows (windows-latest) |
5 h 40 min, 143 705 rounds | no growth: 9.8 MiB at the warm-up peak, at most 10.0 MiB after; 160 handles |
| Soak | Windows 11 workstation | 8 h, 153 626 rounds | no growth: 11.2 MiB at the warm-up peak, at most 11.3 MiB after; 176 handles |
| Fuzz | Linux (ubuntu-latest) |
24 h for each of the 20 targets, in five rounds | no crash; about 190 billion inputs in all, from 1.1 billion (procfs) to 32 billion (pid_file) per target |
The fuzz run found one slow input and no crash. cpu_name ran only 6 million inputs, fewer each round, as its corpus collected names that took one cleaning pass per word: cleaning was quadratic in the name's length, and a 1 MiB name in a container's /proc/cpuinfo would have taken about a minute. Names are now cut to 256 bytes before cleaning (real ones are at most 48); test_attack_t6_hostile_brand_strings_clean_in_bounded_time covers it, and the target ran again for an hour after the fix.