-
Notifications
You must be signed in to change notification settings - Fork 30
[BUG] Path Traversal Vulnerability in Search Path Parameter #201
Copy link
Copy link
Closed
Labels
bugSomething isn't workingSomething isn't workingideIssues related to IDEIssues related to IDEinvalidThis doesn't seem rightThis doesn't seem rightvgrep
Description
Project
vgrep
Description
The search functionality accepts arbitrary paths without validation against path traversal attacks. The path parameter in search requests can contain ../ sequences to escape the intended directory. While canonicalize() is called, it silently falls back to using the original path if canonicalization fails, allowing malicious paths to pass through.
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
- Start vgrep server:
vgrep serve - Send search request with path traversal:
curl -X POST http://127.0.0.1:7777/search \ -H 'Content-Type: application/json' \ -d '{"query":"secret","path":"../../../etc","limit":10}'
- Observe that no validation error is returned
Expected Behavior
- Paths containing
../should be rejected or sanitized - Searches should be restricted to indexed directories only
- Path traversal attempts should return an error
Actual Behavior
- Any path is accepted without validation
canonicalize()failure silently uses original malicious path- If sensitive files were indexed, they could be searched from any context
Additional Context
Location: src/core/search.rs:43
let abs_path = std::fs::canonicalize(path).unwrap_or_else(|_| path.to_path_buf());Security Impact: High - Could allow searching indexed sensitive files outside intended scope.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workingideIssues related to IDEIssues related to IDEinvalidThis doesn't seem rightThis doesn't seem rightvgrep