Repository navigation
test(sandbox): ratchet-aware NoNewPrivs child matrices - #98
Conversation
Hardened containers pin NoNewPrivs=1 across the whole process tree, so the child-matrix rows that expect NNP=0 (the danger-full-access posture and the falsey env override) are unsatisfiable there: the child inherits the pinned flag and the kernel forbids clearing it, and the two matrices failed deterministically in such environments. Probe the parent process kernel flag first; where it is already pinned, assert the ratchet instead (the flag stays 1) and print a disclosure for each substituted row. Unpinned environments (developer machines, CI) still run the full original matrix unchanged. Signed-off-by: asto18089 <asto18089@126.com>
|
Fresh review (from scratch), performed on the branch rebased onto latest Claim verification — first-hand in a pinned-NNP containerThis review environment runs
Completeness (related cases)Repo-wide sweep: these two child-matrix tests are the only tests whose assertion outcome flips under NNP pinning. Every other NNP-adjacent test either injects synthetic SmugglingClean. +37/−0, all inside Elegance / correctness notes (no action required)
Environment notes (pre-existing, not this PR)
GatesAll checks were green except the required |
asto18089
left a comment
There was a problem hiding this comment.
VERDICT: APPROVE (self-review; GitHub blocks formal approval from the author's account).
Fresh review, from scratch, on the branch rebased onto latest pinvou3-clean 0bc868f — content-trivial rebase (applied file blob 6266812595 byte-identical to head). Evidence (full details in the review comment below):
- Claim: reproduced first-hand in this pinned-NoNewPrivs container — pre-fix both child-matrix tests fail deterministically exactly as claimed; post-fix the full no_new_privs set is 14/14 green with disclosure lines for exactly the two unsatisfiable rows. Kernel premises verified empirically (PR_SET_NO_NEW_PRIVS,0 fails EINVAL when set; flag survives fork+exec).
- Completeness: repo-wide sweep — these two matrices are the only tests whose outcome flips under NNP pinning; 14/14 filter count exact; every other NNP-adjacent test injects synthetic values or asserts flag-invariant strings.
- Smuggling: none (+37/−0, single test module, additions only).
- Gates: all 13 checks green (link check fixed by the body No-Issue line); fmt clean; the local clippy hits are pre-existing on base and CI's Analyze (rust) is green.
Non-blocking notes: forwarding-wrapper name slightly overclaims 'pinned'; substitution block duplicated ×2; PR-body 'the downgrade is refused' is shorthand — nothing in production attempts a downgrade. Residual-by-design (disclosed in code): pinned environments cannot detect removal of the PR_SET_NO_NEW_PRIVS application.
JensenChen28
left a comment
There was a problem hiding this comment.
Reviewed current head 28c37d304386bfcbba438632d934871873a0d152. The expectation is adjusted only when the parent process already reports NoNewPrivs=1, where the kernel's one-way ratchet makes an expected-zero child row unobservable; unpinned environments still assert the original zero outcomes. Both child-process matrices pass locally (2/2) in this pinned environment. Current pinvou3-clean does not touch this file, the PR remains mergeable, and the earlier link failure was superseded by the later successful rerun; check and gate are green. Approved.
JensenChen28
left a comment
There was a problem hiding this comment.
Reviewed 28c37d3. No blocking findings. The diff changes only the Linux child-process test expectations when the inherited kernel NoNewPrivs flag is already set. Normal unpinned opt-out expectations remain intact; the pinned substitution is explicitly disclosed, and the production hardening path is unchanged.
Independent Linux validation: compiled the entire current process_hardening.rs unchanged in an isolated Rust crate with libc/tracing (source hashes matched). Ran all module tests in both environments:
- Parent NoNewPrivs=0: test result: 11 passed; 0 failed.
- A separate process explicitly set NoNewPrivs=1 before executing the same test binary: test result: 11 passed; 0 failed. Both changed matrix tests emitted their pinned-state disclosure and passed.
The flag was set only in the dedicated probe process; the review parent remained at 0. This validates the actual kernel behavior and child inheritance on Linux, not just a mocked predicate. Full workspace and non-Linux suites were not rerun. Required checks were rechecked before submission. This approval concerns the CodeWhale PR, not a parent gitlink update.
Summary
Hardened containers pin
NoNewPrivs=1across the whole process tree. The two child-matrix tests insandbox::process_hardening::linux_flag_testsinclude rows that expect the child to reportNNP=0(thedanger-full-accessposture row, and the falseyCODEWHALE_NO_NEW_PRIVS=0override row). Under a pinned kernel flag those rows are unsatisfiable — the child inherits the flag and the kernel forbids clearing it — so both tests failed deterministically in such environments (observed in containerized dev environments; CI and developer machines are unaffected).Fix
Probe the parent process's kernel flag (
no_new_privs_active()) before running each matrix. Where the flag is already pinned:Unpinned environments run the full original matrix unchanged; no row is skipped silently.
Verification
no_new_privsfilter set 14/14 green, disclosure lines emitted for exactly the two unsatisfiable rows.cargo fmt -p codewhale-tui -- --checkclean.No-Issue: test-only fix observed in pinned-NoNewPrivs containers; no tracked issue