Skip to content

Harden (1): Validate seed file paths when creating a repository - #1157

Merged
CleanCut merged 2 commits into
mainfrom
cleancut/harden-1
Nov 2, 2026
Merged

CleanCut merged 2 commits into
mainfrom
cleancut/harden-1

Conversation

@CleanCut

@CleanCut CleanCut commented Nov 2, 2026

Copy link
Copy Markdown
Collaborator

Repository create writes the seed files carried in a create request by joining each file's path onto the new repository. Run every seed path through util::fs::validate_and_normalize_path before the first write, the validation the workspace file routes already apply, so each file lands inside the new repository. It refuses absolute paths, parent-directory components, .oxen components, and empty paths, and validates every entry before writing any, so a refused path fails the create with nothing written. Placing the check in set_up_new_repo confines every caller of repositories::create.

ENG-2429

Repository create writes the seed files carried in a create request by joining
each file's path onto the new repository. Run every seed path through
util::fs::validate_and_normalize_path before the first write, the validation the
workspace file routes already apply, so each file lands inside the new
repository. It refuses absolute paths, parent-directory components, .oxen
components, and empty paths, and validates every entry before writing any, so a
refused path fails the create with nothing written. Placing the check in
set_up_new_repo confines every caller of repositories::create.

ENG-2429
@coderabbitai

coderabbitai Bot commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review.

Recent review info
Run configuration
Commits

Reviewing files that changed from the base of the PR and between a9da4a8 and 44e4622.

Files selected for processing: 2
  • crates/liboxen/src/repositories.rs
  • crates/oxen-server/src/controllers/repositories.rs

Limit details: You’ve used all 4 included reviews currently available.

Summary

Summary by CodeRabbit

  • Bug Fixes
    • Invalid seed-file paths that point outside a new repository are rejected before setup begins, preventing files from being written outside the repository.
    • Requests with an invalid initial file path receive a clear error response.
    • Failed setup attempts clean up the incomplete repository and release its name, allowing creation to be retried with the same name and identifier.

Repository creation now validates and normalizes seed-file paths before initializing the version store or writing files. Invalid paths return validation errors. Tests cover rejected paths, cleanup, name release, and retrying creation with the same name and UUID.

Changes: Seed path validation

Layer / File(s) Summary
Validate seed paths before setup
crates/liboxen/src/repositories.rs
set_up_new_repo validates and normalizes seed paths before setup. Tests check that absolute and parent-traversal paths are rejected without creating a repository or outside canary, and that creation can be retried with the same name and UUID.
Propagate seed path errors
crates/oxen-server/src/controllers/repositories.rs
create_repo_response returns PathOutsideWorkingTree and EmptyPath errors directly. A controller test checks that an outside seed path returns 400 and leaves the name unclaimed.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related PRs

  • Oxen-AI/Oxen#1096: Both changes validate user-supplied file paths before repository content is written or staged.
  • Oxen-AI/Oxen#1121: Both changes validate repository paths before filesystem changes.
Merge Risk: Minimal · up to 44e46

The change safely rejects invalid seed paths and reports them as client errors, with no unresolved merge-blocking risk identified.

Pre-merge checks: Passed 4
Check name Status Explanation
Title check Passed The title names the main change: seed file paths are now validated when a repository is created. It matches the raw summary and the description, which both describe validation in set_up_new_repo and t…
Description check Passed The description states that every seed path goes through util::fs::validate_and_normalize_path before the first write. It lists the rejected cases (absolute paths, parent-directory components, .oxen c…
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.
Full details: Title check

Explanation

The title names the main change: seed file paths are now validated when a repository is created. It matches the raw summary and the description, which both describe validation in set_up_new_repo and the create path. It is specific and does not use vague terms.

Full details: Description check

Explanation

The description states that every seed path goes through util::fs::validate_and_normalize_path before the first write. It lists the rejected cases (absolute paths, parent-directory components, .oxen components, empty paths) and says validation runs before any write. This matches the changeset, which is in repositories.rs and the server controller.

Finishing Touches
Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Usage-based review receipt

Note

This review was completed with usage-based billing: files reviewed beyond your plan's included limits are billed at $0.25/file. View usage-based billing.

@coderabbitai coderabbitai Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Fix comments: Fix CodeRabbit comments on this PR

Comment thread crates/liboxen/src/repositories.rs Resolved
Comment thread crates/liboxen/src/repositories.rs Resolved
Repository create answered a seed file path outside the repository with a 500, since the create
handler's own error mapping turned every error it did not list into a server error. Send these
refusals through the server's shared mapping, which answers 400.
@CleanCut
CleanCut merged commit 1d92948 into main Nov 2, 2026
9 checks passed
@CleanCut
CleanCut deleted the cleancut/harden-1 branch November 2, 2026 23:08
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.

2 participants