Skip to content

security: keep indexed files inside the cloned repository - #1

Open
harshitethic wants to merge 3 commits into
mainfrom
security/confine-repository-files
Open

harshitethic wants to merge 3 commits into
mainfrom
security/confine-repository-files

Conversation

@harshitethic

Copy link
Copy Markdown
Owner

Problem

RepoPilot recursively indexes files from cloned repositories and later reads those files into search/AI context.

The existing iter_files() implementation trusted Path.is_file(). That follows file symlinks, so a repository containing a symlink to a file outside the clone could cause RepoPilot to index and read host-side content.

Example:

repo/
  leaked.py -> /home/user/private.py

Because RepoPilot sends selected repository context to the local model, this violates the intended repository boundary even though cloned project code is never executed.

Fix

  • resolve each candidate path before indexing;
  • require the resolved target to remain under the resolved repository root;
  • reject paths that fail resolution or escape the clone;
  • use the validated resolved file for size checks and downstream reads;
  • keep the existing skip-directory, file-size, and extension filters unchanged.

Tests

Adds regression tests proving:

  • a symlink whose target is outside the repository is excluded;
  • a normal source file inside the repository is still indexed.

The backend CI job now runs the unittest suite in addition to bytecode compilation.

Scope

This protects RepoPilot's read/index boundary. It does not add code execution or change the local-only Ollama behavior.

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.

1 participant