-
Notifications
You must be signed in to change notification settings - Fork 31
[BUG] Symlink Attack Allows Indexing Files Outside Project Directory #64
Copy link
Copy link
Closed
Labels
Description
Project
vgrep
Description
The indexer uses ignore::WalkBuilder without calling .follow_links(false). By default, WalkBuilder follows symbolic links. An attacker who can create symlinks in a project directory can cause vgrep to index files from anywhere on the filesystem, including sensitive system files like /etc/passwd, SSH keys, or other projects.
Error Message
Debug Logs
System Information
Bounty Version: 0.1.0
OS: Ubuntu 24.04 LTS
CPU: AMD EPYC-Genoa Processor (8 cores)
RAM: 15 GBScreenshots
No response
Steps to Reproduce
- Create a project directory with malicious symlinks:
mkdir /tmp/evil_project
cd /tmp/evil_project
ln -s /etc/passwd ./passwd_link
ln -s ~/.ssh ./ssh_link
ln -s /home ./all_users
- Run vgrep indexer on this directory:
cd /tmp/evil_projectvgrep serve &vgrep index - The indexer will follow symlinks and index files from /etc, ~/.ssh, and /home
Expected Behavior
The indexer should either:
- Not follow symlinks by default (.follow_links(false)), OR
- Validate that resolved paths are within the project directory
Actual Behavior
WalkBuilder follows symlinks, indexing files outside the intended directory:
// src/core/indexer.rs lines 55-60
let files: Vec<_> = WalkBuilder::new(&abs_path)
.hidden(false)
.git_ignore(true)
// NO .follow_links(false) - follows symlinks by default!
.build()
Additional Context
No response
Reactions are currently unavailable