Skip to content

fix(config): require owner-only no-follow registry publication - #6375

Merged
lidge-jun merged 4 commits into
devfrom
fix/luvs01-688-owner-registry-20261001
Oct 1, 2026
Merged

lidge-jun merged 4 commits into
devfrom
fix/luvs01-688-owner-registry-20261001

Conversation

@luvs01

@luvs01 luvs01 commented Oct 1, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Owner-registry publication could follow an attacker-planted final-entry symlink, and a permissive registry directory could expose the publication surface. Reject a symlinked registry directory, require the existing owner-only directory hardening helper, and publish entries with the no-follow atomic writer. The required hardening call also applies on Windows; mocked contract checks cover hardening failure and publication ordering.

Source history is preserved through commit e077abf0fbbc1a88f2580c957fe8df4408897b2f. The local validation below used the integration with dev at 0328373fb88fe0d019b29ae278e153d7fed4bcc7.

Verification

Current upstream integration: a6114b62ed1b65dede802359ccd373d913979b24; published HEAD c912ec1bfd3dd8216a7050a5251519f74f3b00df. The source history through 8e1a33352cb89dbd1028d1ded1a6c4c8ae0b5df2 is retained without rewriting authors or commits. The PR-specific change was checked again after this integration; typecheck, structure, privacy and file-size gates passed. Cross-platform CI succeeded for this exact HEAD; its checkout tree matches the published HEAD tree. Skipped jobs remain skipped.

Windows, Bun 1.4.0, isolated test temporary directory:

  • bun test tests/config/owner-registry-acl.test.ts tests/test-layout.test.ts tests/test-layout-tooling.test.ts: 24 passed, 0 failed, 601 assertions. The ACL contract is checked with controlled stubs; these results do not claim a real Windows ACL mutation or a live owner-registry rollout.
  • bun node_modules/typescript/bin/tsc --noEmit: passed.
  • bun scripts/structure-ssot.ts: passed.
  • bun scripts/privacy-scan.ts: passed.
  • bun scripts/file-size-ratchet.ts: passed.
  • git diff --cached --check 0328373fb88fe0d019b29ae278e153d7fed4bcc7: passed.

The full local suite and test:changed were not run under the focused-validation exception because concurrent isolated worktrees made the full suite impractical. Focused contract checks do not replace independent review of real Windows directory ownership and no-follow publication behavior. Exact-HEAD CI succeeded; results from another HEAD are not its verification.

Checklist

  • Scope stays focused and avoids unrelated cleanup.
  • Relevant contracts and regression coverage are recorded with the change.
  • Security-sensitive changes have independent maintainer review; sponsorship is required before merge where the sponsored-surface gate applies.
  • Author validation is documented for c912ec1bfd3dd8216a7050a5251519f74f3b00df, known correct findings are addressed, and exact-HEAD CI is complete; author review readiness is confirmed.

Independent maintainer approval, explicit security review, and any required maintainer-sponsored decision remain pending before merge. These are separate from author review readiness; no approval or sponsorship is claimed.

Summary by CodeRabbit

  • Bug Fixes
    • Owner-registry directories now receive owner-only permissions, and directory symlinks are rejected during publication.
    • Registry entries are written only after required security hardening succeeds. If hardening fails, the entry is not published; registration continues without propagating the failure.

@coderabbitai

coderabbitai Bot commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

🧰 Additional context used
📚 Code guidelines (3)
scripts/AGENTS.md — auto-discovered
src/AGENTS.md — auto-discovered
structure/AGENTS.md — auto-discovered

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository: lidge-jun/opencodex/.coderabbit.yaml

Review profile: ASSERTIVE

Plan: Advanced

Run ID: 96c1723e-c437-4284-8f27-55b4c303ac6f

📥 Commits

Reviewing files that changed from the base of the PR and between a6114b6 and c912ec1.

📒 Files selected for processing (6)
  • scripts/test-layout/layout.json
  • src/config/owner-registry.ts
  • structure/config.md
  • tests/cli/sibling-home-client-sync.test.ts
  • tests/config/owner-registry-acl.test.ts
  • tests/fixtures/test-layout-expected.json

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 2 remain after this review.


📝 Walkthrough

Walkthrough

Owner-registry publication now hardens the registry directory before writing a pointer. The change adds POSIX permission and symlink checks, requires successful directory hardening, clarifies the atomic-writer contract, and adds tests for POSIX and Windows behavior.

Changes

Owner-registry publication

Layer / File(s) Summary
Directory hardening and pointer writing
structure/config.md, src/config/owner-registry.ts
The documented contract requires a non-symlink registry directory, POSIX mode 0700, and successful hardenSecretDir before pointer writing. Registration enforces those checks and writes with atomicWriteFileNoFollow. The atomic-writer documentation also describes Windows hardening calls and memo handling.
Publication tests and test-layout mapping
tests/config/owner-registry-acl.test.ts, tests/cli/sibling-home-client-sync.test.ts, scripts/test-layout/layout.json, tests/fixtures/test-layout-expected.json
Tests cover directory permissions, ACL operations and failures, and symlink handling. The new ACL test is mapped to the config test group.

Priority: ⬇️ Low

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Bug fix

Sequence Diagram(s)

sequenceDiagram
  participant Registration as registerOwnerRegistryHome
  participant Directory as Registry directory
  participant Hardening as hardenSecretDir
  participant Writer as atomicWriteFileNoFollow
  Registration->>Directory: Create with mode 0700 and check directory type
  Registration->>Hardening: Harden registry directory
  Hardening-->>Registration: Return hardening result
  Registration->>Writer: Write pointer after successful hardening
Loading

Merge Risk: ⚪ Minimal · up to c912e

The change strengthens registry publication and prevents publication when directory hardening fails. No actionable merge-blocking risk remains after normal checks; the existing Windows ownership weakness is outside this change.

Security Architecture Review

Security architecture risk: 🔵 Low · up to c912e

The change strengthens publication safety without expanding access or authority. A pre-existing Windows directory-ownership limitation remains, but independent identity and attestation checks limit the consequences of registry tampering.

Retained concerns
No architecture-level concerns identified.

Security review details

Security Blast Radius

  • inferred — The retained attack path requires a local principal able to pre-create or control the registry directory, which also depends on access to its parent namespace. The affected unit is the OS user's shared registry and discovery across its custom homes. Registry tampering can alter discovery, but downstream ownership authority still requires independent identity and attestation checks.

Security Findings and Attack Paths

  • observed — The retained reportable Windows finding is that a foreign NTFS directory owner can retain authority to change its DACL despite reported hardening success. The helper does not compare or replace that owner. This limitation and the registry's exposure predate the PR; the new required gate strengthens publication rather than introducing or materially worsening this condition.

Trust Boundaries and Controls

  • observed — Directory validation and required hardening now precede the sensitive write, and hardening errors terminate that attempt. Final-entry symlinks are not resolved by the selected writer. Parent-path trust remains an assumption, and registry pointers remain untrusted locators rather than authorization decisions.

Resilience and Maintainability Implications

  • observed — Controlled contract tests check hardening-before-publication, failure at each ACL step or timeout, and directory-symlink refusal. They use synthetic principal and ACL runners, so they do not establish live Windows owner enforcement or concurrent security-descriptor behavior.

Hardening Proposals

  • proposed — If exclusive directory ownership is required, validate the Windows security-descriptor owner against the resolved current-user SID before accepting any hardening success path, and reject foreign-owned directories. Validate that policy with live foreign-owner and repeated-publication tests, including cache and partial-failure paths.
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: enforcing owner-only, no-follow publication for the owner registry.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 3 files. (3 skipped: 3 …
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Autopilot is currently an internal CodeRabbit preview.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions github-actions Bot added the bug Something isn't working label Oct 1, 2026
@github-actions

github-actions Bot commented Oct 1, 2026

Copy link
Copy Markdown
Contributor

✅ Deterministic PR hygiene checks passed.

@luvs01
luvs01 marked this pull request as ready for review October 1, 2026 09:18
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, you can upgrade your account or add credits to your account and enable them for code reviews in your settings.

@lidge-jun

Copy link
Copy Markdown
Owner

Maintainer integration record (MAINTAINERS.md, dev-only) — DRAFT from lane L3

  • PR fix(config): require owner-only no-follow registry publication #6375 by @luvs01: fix(config): require owner-only no-follow registry publication.
  • Exact head: c912ec1bfd3dd8216a7050a5251519f74f3b00df. PR base when CI ran: a6114b62ed. Against current dev (7b2deb8059 at check time) git merge-tree is clean. The only shared files with later dev commits are the test-layout registries (scripts/test-layout/layout.json, tests/fixtures/test-layout-expected.json), both of which still parse as JSON in the merged tree.
  • Hosted CI at this head: Cross-platform CI run 36838587916 passed on attempt 1 (pull_request). Jobs: test 1/4 through test 4/4, gates, structure gate, storage policy, docker smoke, api usage, keyring ubuntu, keyring windows, npm-global ubuntu-latest, npm-global windows-latest, ci. React Doctor, hygiene and enforce-target also passed.
  • Local suites: not run, on explicit owner instruction. Hosted CI is the only execution evidence. Local static checks on the union of this lane's PRs over current dev: structure:check and privacy scan pass.
  • Security review (file-permission hardening): an independent read-only review returned PASS bound to c912ec1bfd3dd8216a7050a5251519f74f3b00df. It checked the 0700 directory creation, symlink and junction refusal, the required Windows ACL hardening, the no-follow atomic writer (exclusive 0600 temp, dev/ino check, rename over a planted entry), and that errors stay inside the best-effort registration. One non-blocking note: the directory lstat → chmod → write sequence is not bound to one directory handle. Racing it requires write access to the owner's own ~/.opencodex, which is outside this PR's threat model. A possible later hardening is to open the directory no-follow and use fchmod/fstat with a uid check.
  • Review threads: none open. CodeRabbit reported no actionable comments.
  • Attribution: authored by @luvs01; not a carry.

@lidge-jun
lidge-jun merged commit 6e51011 into dev Oct 1, 2026
42 checks passed
@lidge-jun
lidge-jun deleted the fix/luvs01-688-owner-registry-20261001 branch October 1, 2026 13:49
lidge-jun added a commit that referenced this pull request Oct 1, 2026
On macOS tmpdir() is under /var, a symlink to /private/var. The no-follow writer resolves the registry's parent, so the icacls stub saw /private/var paths, failed its root-prefix assertion inside the swallowed registration and left the registry empty. #6375's CI never ran the macOS shards; this PR does, and macos 1/2 failed at owner-registry-acl.test.ts:72. Test-only fix.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants