Security and reliability review, November 2026
Scope:
crates/tenon-compiler/src/{sandbox_launcher,net_host,manifest}.rs,
crates/tenon-compiler/src/cgen/secret.rs,
crates/tenon-compiler/src/packages/{mod,lock,git,resolve}.rs,
crates/tenon-compiler/src/interp/process.rs,
crates/tenon/src/plugins.rs,
runtime/*.h,
plugins/cli/native/trt_{sandbox,proc,proc_run,proc_plugin,proc_spawn,io,io_cap,io_fs,io_read,app_scope}.h,
and plugins/agent/native/trt_{agent,tools}.h.
Originally reviewed against main at
3d25e914 and reconciled in Track B against the
current tenon / trt_* layout and P1–P9
mitigations.
Severity: High means exploitable by untrusted input with real impact. Medium needs an attacker-controlled repository or a granted capability. Low needs local write access, races or unusual configuration. Info means no defect, but worth knowing.
Fixed in initial review
(3d25e914)
| # | Severity | Where | Finding | Fix and regression test |
|---|---|---|---|---|
| F1 | Medium | crates/tenon-compiler/src/packages/lock.rs
(originally packages.rs:1171) |
tenon fetch wrote the lockfile with
std::fs::write, which follows a symlink. A repository
could commit tenon.lock as a dangling symlink so
fetch wrote attacker-chosen lock text to an arbitrary writable
target; truncate-then-write also let concurrent readers see an
empty lock (E0944). |
Atomic lock writer creates a create_new staging
file beside tenon.lock and renames it
over the lockfile, replacing any symlink and preventing torn
reads. |
| F2 | Low (flaky test) | scripts/test_native_test_cc.py::test_termination_reaches_cache_process_group |
About 1 run in 10 failed under load due to re-entrant stdout
writes from a SIGTERM handler and a lost-wakeup window around
signal.pause(). |
SIGTERM is blocked before fork and consumed with
signal.sigwait. Passed 200/200 runs under 12-way
load. |
| F3 | Low (flaky test) | deps_tests.rs::corpus_resolved_references_are_covered |
Read tests/programs/edition-{args,codec-show} in
place before deps were materialized, causing E0936 on fresh
checkouts or concurrent-fetch races. |
Copies edition/git test programs into a private temp dir, fetches there, and analyzes the copy. |
Track B P1–P9 findings and mitigation status
| # | Severity | Live path | Original finding | Track B mitigation status |
|---|---|---|---|---|
| P1 | Medium | plugins/cli/native/trt_sandbox.h |
With network granted, Linux seccomp allowed every
socket() call including AF_UNIX, letting
sandboxed children reach path/abstract UNIX sockets
(/var/run/docker.sock, D-Bus). |
Mitigated (Track B): When
network=1, the Linux BPF seccomp filter checks
socket() args[0] to allow only
AF_INET/AF_INET6 (returning
EACCES for AF_UNIX and other families)
and adds LANDLOCK_SCOPE_ABSTRACT_UNIX_SOCKET when
Landlock ABI >= 6. |
| P2 | Medium | plugins/cli/native/trt_sandbox.h |
Sandboxed children could kill() same-UID
processes (including the runner or sibling agents) because
Landlock ABI 6 signal scoping was not requested. |
Mitigated (Track B): Linux Landlock ruleset
requests LANDLOCK_SCOPE_SIGNAL (alongside
LANDLOCK_SCOPE_ABSTRACT_UNIX_SOCKET) with exact
ABI-aware struct sizing when Landlock ABI >= 6, preserving ABI
< 6 compatibility. |
| P3 | Medium | plugins/agent/native/trt_tools.h; ADR-0118 |
On platforms other than Linux/macOS (#else),
shared tool servers spawned via plain posix_spawn
with no filesystem or network confinement, unlike all other
sandboxed spawns which fail closed. |
Mitigated (Track B): Replaced the
#else unconfined posix_spawn fallback in
trt_tools_spawn with fail-closed EACCES,
matching trt_proc_spawn.h and
sandbox_launcher.rs. |
| P4 | Low | plugins/agent/native/trt_agent.h,
plugins/cli/native/trt_proc_run.h,
crates/tenon-compiler/src/cgen/secret.rs |
Secret redaction was best-effort: secret buffers were not
zeroed on free, and unsandboxed Process.run inherited
raw environ containing secret env vars. |
Mitigated (Track B, defense-in-depth): Added
volatile zero-wipe on cleanup/free in trt_agent.h and
default scrubbing of registered secret env keys in unsandboxed
Process.run (trt_proc_run.h).
Substring-only stdout/stderr redaction remains best-effort by
design. |
| P5 | Low | plugins/cli/native/trt_proc_plugin.h |
Hashing and fexecve-ing the same descriptor
closed path-swap races, but a same-user writer with write access
to the inode could still modify bytes between hash and exec. |
Mitigated (Track B): Linux copies the plugin
binary into a
memfd_create(MFD_CLOEXEC|MFD_ALLOW_SEALING)
descriptor, applies
F_SEAL_WRITE|F_SEAL_SHRINK|F_SEAL_GROW|F_SEAL_SEAL,
hashes the sealed fd, and executes via fexecve; macOS
executes a 0500 private snapshot. |
| P6 | Low | plugins/cli/native/trt_io_cap.h,
plugins/cli/native/trt_io_fs.h |
Fs capability checks relied on
realpath + prefix check;
trt_cap_fs_resolve lacked the defensive
cap.denied guard present in
trt_cap_fs_resolve_lstat, and symlink-following opens
remained possible unless no_follow() was
enabled. |
Hardened (Track B): Added defensive
if (cap.denied) return cap.denied; guard to
trt_cap_fs_resolve and Fs.no_follow()
enforcement for symlink-free capability roots. Same-user
concurrent TOCTOU remains outside D6's capability-discipline
threat model. |
| P7 | Low | crates/tenon-compiler/src/packages/git.rs |
GIT_ALLOW_PROTOCOL=https:ssh:file allowed
transitive dependency manifests to clone arbitrary local git
repositories readable by the user into
.tenon/deps. |
Mitigated (Track B): Restricted
file in GIT_ALLOW_PROTOCOL in
packages/git.rs to root packages or explicit
--dev usage; transitive dependencies are restricted
to https:ssh. |
| P8 | Low | runtime/trt_map.h |
Default map hash seed 0 (ADR-0053) is
deterministic, allowing attacker-chosen string keys to induce hash
collisions on hostile inputs. |
Mitigated (Track B, opt-in): Added opt-in
TRT_MAP_RANDOM_SEED initialized once via
getrandom (Linux) / arc4random_buf
(macOS/BSD) before first pthread; default seed remains
0 for determinism per ADR-0053. |
| P9 | Low (reliability) | crates/tenon-compiler/src/packages/git.rs |
Re-acquiring a dependency tree renamed the old tree away before moving the new one into place, causing concurrent offline builds in that window to fail with E0936. | Mitigated (Track B): Serialized and locked
atomic dependency swap in packages/git.rs so
concurrent offline builds no longer observe missing dependency
trees during re-acquisition. |
Reviewed, no defect found
- Runtime headers (
runtime/*.handplugins/cli/native/trt_*.h). Allocation sizes are checked before multiplying or adding acrosstrt_try_alloc,trt_str_buffer,trt_vec_buffer,trt_vec_new,trt_vec_concat,trt_vec_join,trt_format,trt_text_parts,trt_chunks,trt_map_copy, the 2^31 map entry cap,trt_path_join,trt_path_components, andtrt_path_display. TheTRT_MEMORY_LIMITandTRT_THREADSparsers reject overflow.trt_memory_limit's lazy static is initialized before the first pthread starts (runtime/trt_par.h). Shifts and rotates are range-checked, and signed/,%, and negation trap or defineINT_MINcases. UTF-8 decoding rejects overlong forms and surrogates. crates/tenon-compiler/src/manifest.rs. Process commands must be relative and canonicalize inside the package. Dependency names are validated identifiers. Git revisions must be 40 lowercase hex digits, and URLs reject a leading-, NUL, and userinfo. Git's rejection of--prefixed ssh hosts coversssh://-o.... FFI headers reject.and..components.crates/tenon-compiler/src/packages/{mod,lock,git,resolve}.rs. Tree hashes reject symlinks and special files (crates/tenon-frontend/src/sha256.rs). The.tenon,deps, name, and revision components aresymlink_metadata-checked, and.tenon/.gitignoremust be a regular file. Staging reaping never follows symlinks. Git runs without the caller'sGIT_DIRfamily, hooks, or submodules. Path dependencies inside a git checkout are confined both lexically and canonically. Lock strings can only contain\nand\tcontrols, whichquoteescapes, because the TOML subset rejects other escapes and raw controls.crates/tenon/src/plugins.rs. Theplugin.index[name.len() + 1..]slice is safe because manifest validation guarantees the ASCIIname:prefix.DOCS.mdreads are read-only and budget-checked.crates/tenon-compiler/src/net_host.rsandtrt_net_host(plugins/cli/native/trt_io_cap.h). The two normalizers accept the same inputs. One informational difference: IPv4-compatible IPv6 text differs (Rust prints::102:304, glibc prints::1.2.3.4). Each backend normalizes both grant and request with its own function, socoversresults agree.crates/tenon-compiler/src/cgen/secret.rs. Guards borrow agent-owned snapshots.tn_secret_guards_freeis registered aftertrt_agent_cleanup, so it runs first at exit, and output is redacted before entering the stdout buffer.crates/tenon-compiler/src/sandbox_launcher.rs. Built into a 0700 private temp dir. Its--pluginargv comes only frominterp/process.rs, never from user input. The macOS branch builds thesandbox-execargv with a proper NULL terminator.crates/tenon-compiler/src/interp/process.rs. Framed helper reads are bounded incrementally.run_inputcaps combined output, kills the whole process group with/bin/kill(no shell, no PATH lookup) on any failure, and always reaps the child.plugins/cli/native/trt_sandbox.h. The SBPL escaper escapes quotes, backslashes, controls, and non-ASCII bytes. Linux appliesNO_NEW_PRIVSbefore Landlock and seccomp. The seccomp filter kills foreign-arch and x32 syscalls and returnsENOSYSforio_uring_setup. A restricted host list fails closed (EACCES) because per-host enforcement does not exist yet.
Pre-existing flaky tests and compiler warnings (initial review)
scripts/test_native_test_cc.py::test_termination_reaches_cache_process_groupfailed ~1 in 10 under load; fixed as F2.deps::tests::corpus_resolved_references_are_coveredraced concurrent package fetches on fresh checkouts; fixed as F3 together with F1.- The gcc 13
-Wmaybe-uninitializedwarning originally noted at3d25e914inplugins/cli/native/trt_app_scope.hwas fixed in PR #171.