Two unauthenticated file-disclosure bugs in the API

Author: AvAl4nchCreated Sep 20, 2026Updated Sep 20, 2026

Two unauthenticated file-read bugs. Tested on current main with uvicorn api.main:app, no credentials. Leaving exact payloads out since there's no private reporting enabled; happy to send them if you turn it on.

1. GET /codemap/file

read_repo_file has a traversal guard, but the root it checks against comes from the request, so it can never fail:

python
repo_dir = os.path.realpath(Repo(repo_url=repo_url, repo_type=repo_type).save_path)
target   = os.path.realpath(os.path.join(repo_dir, file_path))
if os.path.commonpath([repo_dir, target]) != repo_dir:   # always equal

Repo.save_path returns the caller's string whenever it isn't an http/https/ftp URL:

python
if self.is_local:
    return self.repo_url        # attacker picks the confinement root

So .. is correctly rejected, but any absolute path is accepted as the "repository". No auth on the route, and DEEPWIKI_AUTH_MODE defaults to False. Reachable files include the provider API keys.

2. GET /local_repo/structure

No confinement at all: takes path, runs os.walk, returns the full tree plus the first README.md found. Confirmed enumerating directories outside the app. Also an unbounded sync walk in the event loop.

Fix for both: don't let request input choose the root. Pin it to CLONE_REPO_ROOT:

python
allowed = os.path.realpath(CLONE_REPO_ROOT)
if os.path.commonpath([allowed, os.path.realpath(p)]) != allowed:
    raise HTTPException(400, "path outside the managed repository root")

Same applies to the other routes taking repo_url (/codemap/stream, /ws/codemap, /prepare).

Source: AsyncFuncAI/deepwiki-open