Repository navigation
Safety Model
bisu edited this page Sep 21, 2026
·
1 revision
BinaryInspector is built to inspect untrusted files without ever running them. This page lists the guarantees and the mechanisms behind them.
- No execution. The tool never executes, maps, loads, or sends the inspected binary anywhere. It reads bytes and decodes structure.
-
No unsafe code. Both executables are compiled with
#![forbid(unsafe_code)]. The crate's own SHA-256 and entropy code are plain safe Rust; no third-party crypto dependency. -
Panic-free parsing. Every parser path returns
Resultand uses checked arithmetic. Malformed, truncated, or hostile input produces a parse error (exit code 3), never a panic. Release builds additionally setpanic = "abort". -
Regular files only. Symlinks, directories, FIFOs, and device nodes are rejected before any read (
read_regular_file). This removes TOCTOU-style surprises and special-device reads. - Local only. No network access, no telemetry, no update checks.
| Bound | Value | Enforced by |
|---|---|---|
| File size | 512 MiB |
inspect() before reading |
| File type | regular file only |
read_regular_file (lstat check) |
| Read model | single bounded read into owned Vec<u8>
|
input module |
A small file can declare enormous tables; the parser caps every table so declared counts can't turn bounded bytes into unbounded work or allocations:
| Constant | Limit | What it protects |
|---|---|---|
MAX_TABLE_ENTRIES |
65,534 | Program headers, section headers |
MAX_DYNAMIC_ENTRIES |
16,384 |
PT_DYNAMIC entries |
MAX_SYMBOL_ENTRIES |
65,536 | Symbols per table |
MAX_RELOC_ENTRIES |
32,768 | Relocations |
MAX_NOTE_ENTRIES |
8,192 | ELF notes |
MAX_STRING_BYTES |
4,096 | Any single string from the file |
MAX_TOTAL_TEXT_BYTES |
4 MiB | All emitted text combined |
MAX_TOTAL_SECTION_SCAN_BYTES |
64 MiB | Total section-content scanning |
Any structure beyond its cap fails with a LimitExceeded error rather than being silently truncated.
- Binary-provided strings are rendered as printable ASCII with every other byte escaped as
\xNN— deterministic and terminal-safe (no control-character injection in your shell). - JSON is emitted through
serde_json; JSON output goes only to stdout, human logs to stderr. - Report vectors preserve file order; no user-visible output depends on hash-map iteration, so output is deterministic for identical inputs.
untrusted bytes -> input validation -> elf parser (checked, capped)
-> Binary model (validated owned values) -> report (sanitized text / JSON)
Data flows one way. Untrusted bytes never reach reporting; reporting only sees validated, owned domain values.
Installation