Repository navigation
fix(pr): tolerate mode-inert filesystems in private-file validation - #4135
lmktechnology wants to merge 9 commits into
Conversation
|
Speaking as Kun's firstmate: Tip First-time CI approved after diff review (narrow private-file validation fix; looks safe): CI run Contract-class: restore. Unconfigured PR poll/check/merge already promised private-file validation; on mode-inert noacl/posix=0 (and drvfs/9p) mounts chmod cannot satisfy exact mode 600, so the promised path was unusable. Fix probes device capability and skips only the exact-mode equality when proven inert; regular-file / non-symlink / device / single-hard-link checks stay unconditional; capable devices keep exact mode. Restores already-promised default behavior on inert mounts without loosening capable ones. VISION.md (each rule)
Security FYI (not waiting-captain): (1) inert path drops bit check by design when chmod is a no-op — residual risk if a device were misclassified inert (probe requires both 600 and 640 to track); (2) pipeline review notes Outcome: waiting-ci. Blockers: CI not yet reported post-approval. Do not merge this pass. Auto-merge eligible class (restore) once CI green + MATCH holds. |
|
A data point for this from a native Windows trial, in case it helps prioritise. Environment: Windows 10.0.26200, Git for Windows 2.44.0 (MINGW64, MSYS 3.4.10), firstmate Observed: Things tried: a user mount with There is no separate issue for this; this PR (and #2919, #1736) is where it is being discussed. |
|
Speaking as Kun's firstmate: thanks @lmktechnology, and thanks @Prophet7771 for the native Windows data point. It confirms the failure mode on a stock Git for Windows Where it stands: waiting on you, for one thing. The no-mistakes attestation binds The branch also has a merge conflict with main now. That's ours to fix on a merge word, and you don't need to do anything about it. Contract class (my own read, which corrects my September comment): new-default, not restore. Main promises an exact-mode private-file check and advertises macOS and Linux. It never promised PR poll and check on mode-inert mounts. With this change, every unconfigured run on such a device accepts private files without the mode check. That trade is security-sensitive, so whether to ship it as a default is Kun's call at merge time. It won't auto-merge. The probe design itself is careful: it is a live chmod probe rather than mount-string parsing, it is cached per device, and the regular-file, not-a-symlink, device and single-link invariants stay unconditional. VISION: aligns on scripts-own-mechanics, delegation, restart and vendor portability. Authority and scope are the captain's decision for the reason above. Related: #2919 and #1736 target the same mode-inert bug class. |
Intent
Fix PR recording and merge being impossible on noacl Windows mounts. bin/fm-pr-check.sh always fails with 'error: could not prepare PR poll' because fm_pr_poll_prepare in bin/fm-pr-lib.sh runs chmod 0600 on its temp files and then requires fm_pr_private_file_valid to observe mode exactly 600, but on noacl/posix=0 NTFS mounts (Git-Bash/MSYS) and drvfs/9p-backed WSL mounts chmod cannot represent POSIX permission bits (chmod 0600 silently leaves files at other modes, e.g. 755/700/777), so the equality check can never pass and bin/fm-pr-merge.sh becomes unusable for every PR on these hosts. This task touches firstmate's own shared tracked material under bin/, so firstmate-coding-guidelines applies. Definition of done: make the private-file validation express the real security intent (no group/other access) in a way that is satisfiable where the filesystem cannot represent POSIX modes, without weakening the check on platforms that can, by detecting noacl/posix=0 (and drvfs/9p-style) mounts explicitly rather than loosening the check everywhere. Acceptance criteria: (1) bin/fm-pr-check.sh and bin/fm-pr-merge.sh work correctly on a noacl/posix=0 mount without weakening the private-file check on a mount that can honor POSIX modes; (2) the check still meaningfully rejects a file that is genuinely group/other-readable on a platform where that's representable; (3) add regression coverage for both the honor-capable and mode-inert filesystem cases.
What Changed
fm_pr_device_mode_capabletobin/fm-pr-lib.sh, which probes a device by chmod'ing a scratch file to two different modes and checking whether the observed mode tracks each request, caching the capable/inert result per device for the process lifetime.fm_pr_private_file_validto skip the exact-mode equality check only when the probe proves the file's device cannot represent POSIX mode bits (noacl/posix=0 NTFS or drvfs/9p-backed mounts); the regular-file, non-symlink, device, and single-hard-link checks still apply unconditionally, and mode-capable devices still get the exact mode check with no loosening.fm_custom_check_snapshot_prepareinbin/fm-check-lib.shto route its private-file checks throughfm_pr_private_file_validinstead of its own inline mode/device/link-count checks.tests/fm-pr-check-security.test.shwith a fakebin harness (install_mode_probe_fakebin) that simulates capable and inert chmod behavior, and added regression tests covering both the honor-capable and mode-inert device cases; existing tests that assert exact mode bits now force the capable simulation via the fakebin rather than relying on the ambient test host's filesystem.docs/fm-test-isolation-proof.mdthat the recordedfm-pr-check-securitytiming predates this fix and should be refreshed.🤖 Generated with Claude Code
Risk Assessment
✅ Low: The fix is narrowly scoped to fm-pr-lib.sh's private-file validation, correctly detects mode-inert mounts via a live two-step chmod probe (verified against actual bash if/no-else-false-condition returns-0 semantics), preserves the exact-mode check unweakened on capable devices, keeps every other invariant (regular file, no symlink, device match, single hard link) enforced unconditionally on inert devices, and is backed by thorough new regression tests simulating both capable and inert filesystems plus an end-to-end poll prepare/publish/validate test on a simulated inert device, satisfying all three stated acceptance criteria.
Testing
Reproduced the reported noacl/posix=0 Windows bug live on this session's actual affected mount using the pre-fix code, then confirmed the fix resolves it on the same real mount both via direct fm_pr_private_file_valid calls and via the full real fm_pr_poll_prepare/publish/validate pipeline underlying bin/fm-pr-check.sh; all targeted new and existing regression tests for the mode-capable/mode-inert private-file check passed, and a separate host-specific bash quirk in an unrelated parser test was confirmed pre-existing (reproduces on the base commit too) rather than caused by this change.
Evidence: PR poll noacl/posix=0 mount verification transcript
Source: PR poll noacl/posix=0 mount verification transcript
Pipeline
Updates from git push no-mistakes
✅ **intent** - passed
✅ No issues found.
✅ **Rebase** - passed
✅ No issues found.
bin/fm-procevent-lib.sh:422- bin/fm-mail-check.sh:267, bin/fm-procevent-lib.sh:422/1161, and bin/fm-tool-update-check.sh:767 do a raw[ "$(fm_pr_file_mode ...)" = 600/700 ]equality check instead of routing through fm_pr_private_file_valid, so they retain the same noacl/posix=0 chmod-inertness bug this change fixes for the PR-recording path. The user intent explicitly scopes acceptance criteria to bin/fm-pr-check.sh and bin/fm-pr-merge.sh, so leaving these untouched is consistent with the stated scope; noting for awareness only.Manual repro: sourced base-commit (3e817d3f) bin/fm-pr-lib.sh and confirmed fm_pr_private_file_valid rejects a chmod-0600'd file on this session's real noacl,posix=0 NTFS mount, reproducing the reported bugManual verification: sourced target-commit (a5ae60e) bin/fm-pr-lib.sh on the same real mount and confirmed fm_pr_private_file_valid now accepts the file via the new fm_pr_device_mode_capable probeReal end-to-end run of fm_pr_poll_prepare -> fm_pr_poll_publish_prepared -> fm_pr_poll_artifacts_valid (bin/fm-pr-check.sh's underlying code path), unmodified, on the real noacl mount -- all three steps succeededtests/fm-pr-check-security.test.sh: test_mode_capable_device_enforces_exact_bitstests/fm-pr-check-security.test.sh: test_mode_inert_device_skips_bit_check_but_keeps_other_invariantstests/fm-pr-check-security.test.sh: test_poll_prepare_and_publish_succeed_on_simulated_mode_inert_devicetests/fm-pr-check-security.test.sh: test_poll_publication_refuses_unsafe_destinationstests/fm-pr-check-security.test.sh: test_live_artifact_single_link_and_privacy_validationConfirmed test_parser_matrix's raw-byte-URL failure reproduces identically against the base commit's unmodified fm_pr_url_parse/INVALID_URLS, isolating it as pre-existing host flakiness unrelated to this diff🔧 **Document** - 1 issue found → auto-fixed ✅
🔧 Fix: Flag stale pr-forge timing in isolation-proof doc
✅ Re-checked - no issues remain.
⏭️ **Lint** - skipped
✅ **Push** - passed
✅ No issues found.