fix: tighten helper lookup, private fallback dir, and file locks - #54
Merged
Merged
Conversation
Stop Linux helper resolution from searching /usr/local/bin or following symlinks, matching the macOS allowlist. Create the HOME-less observation fallback with getrandom entropy, O_EXCL, and mode 0700. Replace unmaintained fs2 with fs4 for exclusive ledger and Windows init locks. Amp-Thread-ID: https://ampcode.com/threads/T-01a0a632-d0b9-760e-a38f-da94049550f9 Co-authored-by: Max Carter <undivisible@vk.com>
|
Capy couldn't review this pull request because Max's workspace is out of credits, add credits or enable auto-reload to resume automatic reviews. |
Bugbot couldn't run - usage limit reachedBugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit. A user or team admin can review and increase usage limits in the Cursor dashboard. (requestId: serverGenReqId_fb2d70eb-3b50-47c6-971a-967b78e23d21) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Follow-up to the leftover items from the Praefectus maintenance cycle. Separate from #53 (orb setup / CI pin).
secure_commandnow matches macOS:/usr/bin,/usr/sbin,/bin,/sbinonly. Rejects empty names, path separators, NULs, and does not follow symlinks.fallback_temp_diruses 128-bitgetrandomentropy,create_direxclusive create, Unix mode0700at creation, and retries on collision.fs2withfs41.1 (synconly). Ledger and Windows initialization locks callfs4::FileExt::{lock,unlock}by fully-qualified path to avoidstd::fs::File::lockname collisions.Does not change execute, authority, fencing, or CDP. Not auto-merging: locking + helper-path security.
Test plan
cargo fmt --all -- --checkcargo clippy --locked --all-targets --all-features -- -D warningson 1.88 and stablecargo test --locked --all-features(171 tests, including newsecure_commandand fallback-dir privacy checks)Note
Medium Risk
Changes helper executable resolution and cross-platform file locking used for the operations ledger and Windows init; misbehavior could break startup or weaken path trust, though scope is limited to locking and subprocess lookup—not execute/authority paths.
Overview
Hardens how Praefectus resolves helper binaries, creates its private state directory, and takes file locks.
secure_commandon macOS and Linux now rejects empty names, path separators, and NULs; searches only/usr/bin,/usr/sbin,/bin, and/sbin(Linux no longer uses/usr/local/bin); and refuses symlink targets viasymlink_metadata. Linux gains unit tests for injection and path allowlisting.fallback_temp_dirno longer uses a one-shot hasher under the system temp dir. It loops on 128-bitgetrandomnames, creates the directory exclusively (retry on collision), and on Unix sets mode 0700 at creation; tests assert directory type, permissions, and name shape.Locking dependency: unmaintained
fs2is replaced byfs41.1 (synconly). Ledger locks and Windows initialization locks callfs4::FileExt::lock/unlockwith fully qualified paths.getrandomis added as a direct dependency; lockfile dropswinapipulled in byfs2.Reviewed by Cursor Bugbot for commit 06592fa. Configure here.