Skip to content

fix(core): enforce resolved project root ancestry - #1921

Merged
phernandez merged 2 commits into
mainfrom
codex/security-project-root-ancestry
Oct 28, 2026
Merged

phernandez merged 2 commits into
mainfrom
codex/security-project-root-ancestry

Conversation

@phernandez

Copy link
Copy Markdown
Member

Why

An existing symlink under the configured project root can resolve to a sibling whose name starts with the root's name. The string-prefix check accepts that outside directory. A link to the shared root also passes, registering shared storage as one project's directory. Fixes #1891.

What Changed

Require the resolved project path to be a strict descendant of the resolved configured root before configuration or database writes.

Implementation Details

Use Path.is_relative_to and reject equality with the shared root. Preserve accepted ordinary descendants and symlinks whose targets remain inside the configured root. Real temporary symlinks exercise the service and database boundaries; rejection tests verify config bytes and project rows remain unchanged.

Stacked on #1920. Only the project-root check and its regression tests are new here.

Testing

  • Before the fix: sibling-prefix and shared-root symlink regressions failed because creation succeeded; unrelated outside targets were already rejected.
  • uv run pytest tests/services/test_project_root_containment.py tests/services/test_project_service.py tests/services/test_project_service_operations.py -q --no-cov: 78 passed, 2 existing skips.
  • just fast-check: passed, including repository type checking.
  • just doctor: passed sandboxed write/index/search self-test.
  • git diff --check: passed.

Risks / Follow-ups

This addresses configured local-root containment; it does not establish a hosted tenant escape. Symlink regressions skip Windows, where creating directory symlinks requires privileges. Project-move destination policy remains tracked separately by #1896. This does not add filesystem race protection against a concurrent local process replacing symlinks.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 28, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-28T20:29:10.869348Z 865c252 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

Base automatically changed from codex/security-section-scanning to main October 28, 2026 22:15
@phernandez
phernandez changed the base branch from codex/security-section-scanning to main October 28, 2026 22:15
@phernandez
phernandez merged commit e46f1b4 into main Oct 28, 2026
50 checks passed
@phernandez
phernandez deleted the codex/security-project-root-ancestry branch October 28, 2026 22:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Check resolved project ancestry without string-prefix containment

1 participant