Skip to content

[BUG] Symlink Attack Allows Indexing Files Outside Project Directory #64

@EnthusiasticTech

Description

@EnthusiasticTech

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 GB

Screenshots

No response

Steps to Reproduce

  1. 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
  1. Run vgrep indexer on this directory:
    cd /tmp/evil_projectvgrep serve &vgrep index
  2. 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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions