Repository navigation
T91 — Check that min-answerer links only system libraries - #1954
norrietaylor merged 8 commits into
Conversation
min-answerer is the always-on box-zone answerer the host's service manager holds as a root service (NET-122 to NET-128), so a dependency it resolves from a user-writable path — or an RPATH/RUNPATH/LC_RPATH entry baked into the binary pointing at one — is user-chosen code running as root. scripts/check-answerer-links.sh fails any binary that does, naming each offender: on Linux every ldd entry must resolve inside the loader's default dirs (/lib, /lib64, /usr/lib, /usr/lib64) or be linux-vdso, an unresolvable entry is refused too, and readelf -d must show no RPATH and no RUNPATH entry at all; on macOS every otool -L entry must live under /usr/lib or /System, and otool -l must show no LC_RPATH load command at all. Each dependency and each rpath entry is printed with its verdict, one line per entry, and the gate fails closed on anything it cannot inspect. The harness builds real fixtures with the host compiler: static and system-only positives, and one negative per offender class (a non-system .so or dylib, an RPATH, a RUNPATH, an LC_RPATH), each asserted to fail naming its offender. Each OS runs only its own half and says so on one named line when the other is skipped.
|
Important Review skippedBot user detected. To trigger a single review, invoke the ⚙️ Run configuration
You can disable this status message by setting the Use the checkbox below for a quick retry:
Comment |
|
/review |
|
Approved: no findings at Nothing to do. Verdict APPROVE, posted as a comment: the App cannot review its own pull request; the check and the label carry it. Clobber: none: |
|
/revise Apply three design conditions to scripts/check-answerer-links.sh and its harness. Stay inside the two files this task owns.
Keep failing closed and keep one named verdict line per entry. Both halves of |
Three conditions the answerer link gate did not hold: - Its verdict depended on who ran it. ldd honours LD_LIBRARY_PATH, so the same binary resolved differently in CI and in a developer's shell, and LD_LIBRARY_PATH could make an unresolvable dependency resolve. ldd now runs under `env -u LD_LIBRARY_PATH -u LD_PRELOAD`, matching the clean environment the service manager starts the answerer with, and the header comment says why instead of claiming ldd's view is the user's. The non-system .so negative now resolves through a real DT_NEEDED path — the fixture library is linked by path with no SONAME, so the loader loads it directly — rather than through LD_LIBRARY_PATH. - The system dirs were prefix-matched, which refused /usr/local/lib but not a `..` component: /usr/lib/../../tmp/libnope.so starts inside a system dir and passed. Every path the gate inspects now goes through one shared whole-component check (a path is in /usr/lib only when it starts /usr/lib/, so /usr/local/lib, /usr/lib-x and /usr/libexec are not) that also refuses any path carrying a `..` component, naming the offender either way. - The ELF program interpreter was never looked at, and ldd cannot stand in for it: it maps a non-system PT_INTERP onto the system loader and reports it satisfied. readelf -l now runs first, so a binary linked with --dynamic-linker at a user-writable path is named as the offender before anything else is checked; a static binary has none and passes. The harness covers each: the scrub is proved rather than asserted (LD_LIBRARY_PATH at the directory holding the library fails to rescue a nowhere-resolving dependency), a real ..-spelled DT_NEEDED fixture is built by naming the fixture library through /<system dir>/../../<tmp>, a --dynamic-linker fixture asserts the interpreter is named, and the paths no unprivileged build can produce (/usr/local/lib, /usr/lib-x, /usr/libexec, the .. spellings) are table-checked with canned ldd and otool output on every host — the only place the macOS parsing runs on Linux, since no macOS CI lane runs this harness.
The table harness stored each canned output as <tool>.<flag>, so otool.-L and otool.-l collided on a case-insensitive filesystem and the macOS table cases read the load commands as dependencies. Mark upper-case flag letters in the file name.
|
The runtime will not revise this pull request again on its own: round 2 would exceed the cap of 1 (the last trigger was the runtime's review findings). A person decides now. Remove |
…k check glibc ldd prints a warning line for a binary without the exec bit and then lists its dependencies as usual; the parser refused that line as unrecognized.
|
Round 1 of 1 on a /revise note, pushed as
Verify Converted to a draft: something above needs a person before review. The link check still passes a system-only binary (static, with no interpreter to check, and dynamic, with a system one) and now fails — naming the offender on a verdict line of its own — any binary whose dependency, install name or ELF program interpreter resolves outside the whole system dirs (/lib, /lib64, /usr/lib, /usr/lib64 on Linux; /usr/lib, /System on macOS), or carries a .. path component, or carries any RPATH, RUNPATH or LC_RPATH entry, and its verdict no longer depends on LD_LIBRARY_PATH or LD_PRELOAD. Notes from the agent: Revise round: the directive's three design conditions, all inside the two files the task owns. (1) ldd now runs under |
|
The runtime will not revise this pull request again on its own: round 2 would exceed the cap of 1 (the last trigger was the runtime's review findings). A person decides now. Remove |
norrietaylor
left a comment
There was a problem hiding this comment.
Approved at 8afb557. The link check rules match the design: scrubbed loader environment, whole-component paths with no '..', PT_INTERP check, no rpath of any kind, and a fail-closed parser. ARCH PASS. The harness is green on both halves (macOS 18, Linux 30) and every lane is green.
T91 — Check that min-answerer links only system libraries
slice: S9
kind: task
covers: NET-122
size: S
est: 80 code, 140 tests
executor: agent
difficulty: needs care
model: strongest
diagnostics: the link check prints each dynamic dependency, RPATH/RUNPATH or LC_RPATH entry it found with its verdict and names each offender, so a build that would install a root service able to resolve a user-writable library fails with the library named
observability: one line per checked dependency; one named line when the OS-native half is skipped on the other OS
layers:
- release:
- scripts/check-answerer-links.sh (new): fails unless the given binary resolves only system libraries, naming each offender: on Linux,
lddentries only in the loader's default dirs (/lib, /lib64, /usr/lib, /usr/lib64 and their multiarch subdirs) or linux-vdso, and no RPATH or RUNPATH entry at all inreadelf -d; on macOS,otool -Lentries only under /usr/lib and /System, and no LC_RPATH load command at all inotool -l- scripts/check-answerer-links_test.sh (new): builds fixture binaries in the test; positives are a static Linux binary and a macOS binary linking only /usr/lib and /System; negatives are one each for a non-system .so or dylib, an RPATH, a RUNPATH and an LC_RPATH, each asserted to name its offender; the OS-native half for the other OS is skipped with a named line, never silently
test: bash scripts/check-answerer-links_test.sh
produces:
- scripts/check-answerer-links.sh
consumes: none
proof: The link check passes a system-only binary and fails, naming the offender, any binary with a non-system library or any RPATH, RUNPATH or LC_RPATH entry.
Proof
scripts/check-answerer-links.sh now exists: run it on a binary and it prints one line per dynamic dependency and per RPATH/RUNPATH/LC_RPATH entry with its verdict, and it exits 0 only for a binary that resolves solely from the loader's default dirs (/lib, /lib64, /usr/lib, /usr/lib64 on Linux, /usr/lib and /System on macOS) with no embedded search path at all — a binary with a non-system library, an RPATH, a RUNPATH or an LC_RPATH exits 1 naming the offending entry and its path, and so does anything it cannot inspect. The harness proves each case with fixture binaries it builds itself, and skips the other OS's half with one named line, never silently.
Notes from the agent: The macOS half of the harness is written (clang builds a /usr/lib-only positive, a non-system-dylib negative and an LC_RPATH negative; otool parsing for check-answerer-links.sh is implemented) but cannot be executed on this Linux box — it is skipped with a named line here and will run where otool exists, e.g.
just test-shellon a macOS host. Both files are committed with the executable bit (git mode 100755) like every other script under scripts/, because the harness invokes the gate directly. The non-system-.so fixture resolves its library through LD_LIBRARY_PATH rather than an embedded rpath, so it offends in exactly one class; the check deliberately reads what ldd reports, including env-driven resolution, which is the release-gate threat it exists to catch. No files outside the two named layers were touched.Tests
bash scripts/check-answerer-links_test.shVerify
min task run agent-verifyexited 101, so this PR is a draft.Closes #1947