Prerequisites
Install Method
Other (GitHub-hosted Actions / the repository's advanced CodeQL workflow)
Operating System
Linux
Steps to Reproduce
- On current
dev, inspect the personal-directory indexing flow from routes/personal_routes.py to src/rag_vector.py::index_personal_documents.
- The admin-only route resolves the requested directory with
os.path.realpath() and confines it under PERSONAL_DIR with os.path.commonpath() before passing it to the filesystem walk.
- Make a behavior-preserving edit at the existing
os.walk(directory) site, such as exposing the dirs tuple element so the walk can prune selected directories.
- Open a PR and let the Python CodeQL job run.
Expected Behaviour
The normalized safe-root check should be recognized as a barrier for the user-derived directory before it reaches os.walk(). A behavior-preserving edit at the downstream walk should not create a new high-severity py/path-injection alert for the same already-confined flow.
Actual Behaviour
The dismissed dev finding and the PR finding were tracked as separate alerts:
Alert #638 has since also been dismissed as a false positive. The underlying source shape still uses commonpath(), so another nearby edit can repeat the triage cycle.
Logs / Screenshots
CodeQL 2.26.1
Rule: py/path-injection
Dev alert: #398 (dismissed false positive)
PR #5633 alert: #638 (dismissed false positive)
Sink: src/rag_vector.py::index_personal_documents -> os.walk(directory)
Model / Backend (if relevant)
N/A
Are you willing to submit a fix?
Yes — I can open a PR
Additional Information
A narrow fix can keep realpath() symlink resolution and apply an explicit startswith() guard in each request-to-sink route, followed by an exact-root or separator-delimited descendant check. Direct regressions can cover both add/remove routes, exact-root and descendant acceptance, and parent, sibling-prefix, and symlink-escape rejection. This follows CodeQL's documented normalize-then-prefix-check pattern without disabling the query, filtering SARIF, excluding the file, or lowering the alert severity.
Related work:
Prerequisites
devbranch.Install Method
Other (GitHub-hosted Actions / the repository's advanced CodeQL workflow)
Operating System
Linux
Steps to Reproduce
dev, inspect the personal-directory indexing flow fromroutes/personal_routes.pytosrc/rag_vector.py::index_personal_documents.os.path.realpath()and confines it underPERSONAL_DIRwithos.path.commonpath()before passing it to the filesystem walk.os.walk(directory)site, such as exposing thedirstuple element so the walk can prune selected directories.Expected Behaviour
The normalized safe-root check should be recognized as a barrier for the user-derived directory before it reaches
os.walk(). A behavior-preserving edit at the downstream walk should not create a new high-severitypy/path-injectionalert for the same already-confined flow.Actual Behaviour
The dismissed
devfinding and the PR finding were tracked as separate alerts:devflow;Alert #638 has since also been dismissed as a false positive. The underlying source shape still uses
commonpath(), so another nearby edit can repeat the triage cycle.Logs / Screenshots
Model / Backend (if relevant)
N/A
Are you willing to submit a fix?
Yes — I can open a PR
Additional Information
A narrow fix can keep
realpath()symlink resolution and apply an explicitstartswith()guard in each request-to-sink route, followed by an exact-root or separator-delimited descendant check. Direct regressions can cover both add/remove routes, exact-root and descendant acceptance, and parent, sibling-prefix, and symlink-escape rejection. This follows CodeQL's documented normalize-then-prefix-check pattern without disabling the query, filtering SARIF, excluding the file, or lowering the alert severity.Related work: