Docs/Evidence
Security Model
FrankenNumPy's security posture covers more than memory safety.
- Safe-Rust numeric core. 10 of the 11 implementation crates declare
#![forbid(unsafe_code)]and contain zero hand-writtenunsafe. The 11th (fnp-python) does not declare the lint: PyO3's procedural macros expand tounsafeat the cdylib boundary, andcrates/fnp-python/src/lib.rscontains 67 auditedunsafeblocks/items (consolidated from 1,250 in beaddeadlock-audit-rc0923-epic-71qy3.21by encapsulating ~1,000PyBuffer/ReadOnlyCell/PyArrayObjectslice views behindreadonly_cells_as_slice,slice_as_readonly_cells,PyBufferExt, andNdarrayRaw), with#![forbid(unsafe_op_in_unsafe_fn)],#![deny(clippy::undocumented_unsafe_blocks)], 100%// SAFETY:comment coverage, and a structural budget ceiling enforced byfnp_python_unsafe_blocks_are_encapsulated_and_documentedincrates/fnp-conformance/tests/codebase_hygiene.rs. Thecodebase_hygienesuite also enforces that the other 10 crates stay completely unsafe-free. - Fail-closed by default. Unknown wire formats, unrecognized dtype descriptors, future metadata-version markers, and metadata schema violations cause explicit errors, not silent fallbacks.
- Bounded resource consumption. NPY header caps at 64 KB. NPZ archives cap at 4,096 members and 2 GiB uncompressed. Text I/O caps at 16,777,216 elements. Memmap validation retries cap at 64. These prevent denial of service via crafted inputs to the
fnp-ioRust API. From Python they guardfnp_python.loadin hardened mode only: strict mode decodes a plain.npypath through fnp-io and gives file-like objects and every.npztonumpy.load, as NumPy would (ledger rowDIV-HARDENED-LOAD-BOUNDS). - Pickle rejection. Object dtype arrays that could execute arbitrary code during deserialization require explicit
allow_pickle=true, matching NumPy's security gate. - Adversarial conformance. The security gate (
run_security_gate) tests exploit scenarios from a versioned threat matrix mapped to specific parser / IO / shape-validation boundaries. - No production code mocks or stubs. Structurally enforced by
crates/fnp-conformance/tests/codebase_hygiene.rs— 12#[test]functions, which fail CI ifunimplemented!,todo!,FIXME,HACK,XXX, stub comments,panic!("not implemented"),dbg!()in library code, or#[allow(unused_*)]in library code appear incrates/*/src/; four more keep hand-writtenunsafeout of every crate butfnp-python, forbidallow(unsafe_code)overrides andstd::archintrinsics in every crate, and keep ufunc-shadowed#[pyfunction]s unregistered, andtest_count_sanity_checkasserts the workspace stays above 6,000#[test]functions. Theno_allow_unused_in_library_codetest is the subtle one: theunused_*warning family is what catches stale code paths that would otherwise rot silently, so suppressing it via#[allow(unused_*)]is treated as a stub marker. The human-readable audit atdocs/planning/audit_numpy_mocks.md(dated 2026-05-14) is the companion document with per-site analysis. It predates the current panic-site count; see the Error Taxonomy section.